Metadata-Version: 2.5
Name: judgeproof
Version: 0.1.2
Summary: Checks for your evals: prove your LLM judge agrees with your humans and sees what it needs, and fail CI when it doesn't.
Project-URL: Homepage, https://github.com/woqsi/judgeproof
Project-URL: Website, https://woq.si/tools/judgeproof/
Project-URL: Source, https://github.com/woqsi/judgeproof
Project-URL: Issues, https://github.com/woqsi/judgeproof/issues
Project-URL: Changelog, https://github.com/woqsi/judgeproof/blob/main/CHANGELOG.md
Author-email: Woq <hello@woq.si>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ci,cohen-kappa,evals,evaluation,llm,llm-as-a-judge
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# judgeproof

**Checks for your evals.** Prove your LLM judge agrees with your humans and sees what it needs, and fail CI when it doesn't.

[![CI](https://github.com/woqsi/judgeproof/actions/workflows/ci.yml/badge.svg)](https://github.com/woqsi/judgeproof/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/judgeproof)](https://pypi.org/project/judgeproof/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/woqsi/judgeproof/blob/main/LICENSE)

Most eval tools help you *write* evals. judgeproof checks whether you can trust the judge that scores them.

- **Agreement.** Point it at a CSV of human and judge labels. You get agreement and Cohen's kappa with confidence intervals, plus per-label recall, so a judge that never catches the rare failure can't hide behind 87% accuracy.
- **Input.** Point it at an agent run and at what the judge actually received. It tells you whether the judge saw the tool calls, arguments and results it was asked to grade.

Every check exits non-zero when it fails, so it can gate a pull request. judgeproof works alongside DeepEval, Inspect, promptfoo, Opik, Phoenix, Langfuse and the rest; it doesn't replace them.

```bash
pip install judgeproof
```

![judgeproof demo: an agreement report on 984 MT-Bench labels fails the kappa and recall gates, then an input check shows Inspect's default judge request is missing the agent's tool calls](https://raw.githubusercontent.com/woqsi/judgeproof/main/docs/demo.gif)

Python 3.10+. The only dependency is numpy.

## Why

What we found when we tested this ourselves (full write-ups in [`examples/`](https://github.com/woqsi/judgeproof/tree/main/examples/)):

- **High agreement can hide a judge that misses what matters.** On 984 MT-Bench items, GPT-4 agreed with expert raters 87.4% of the time. When the question became "did the weaker model win?", a judge that *always* said "no" scored 85.0%. GPT-4 caught only 29% of the upsets the experts saw. Kappa and per-label recall show this; raw agreement doesn't. ([examples/mt-bench](https://github.com/woqsi/judgeproof/tree/main/examples/mt-bench/))
- **Your judge may never see the tool calls.** We sent one agent run through five popular eval tools' agent-judging features. In three of eleven routes, the judge was asked whether the agent's promise matched the policy it looked up, without ever being shown that policy. ([examples/five-tools](https://github.com/woqsi/judgeproof/tree/main/examples/five-tools/))
- **And it changes the grade.** We had a real OpenAI judge grade 40 support-bot runs through Inspect, with and without the tool calls. Without them, it failed every correct reply that promised a credit, because it couldn't check the policy, and turning reasoning on made it pass more wrong replies (23 of 72, up from 10). With the tool calls but reasoning off, the small judge still passed about a third of wrong credit offers; with reasoning on it passed none. ([examples/real-judge](https://github.com/woqsi/judgeproof/tree/main/examples/real-judge/); write-up: [blog post](https://woq.si/blog/llm-as-a-judge-tool-calls/))

## Quick start

### 1. Does the judge agree with your humans?

Give it a CSV with one row per labeled example. Labels can be any strings: pass/fail, 1–5, good/ok/bad.

```csv
id,human,judge
t-001,pass,pass
t-002,fail,pass
```

```bash
judgeproof agreement labels.csv
```

```
== all rows ==
rows: 984  (distinct ids: 984)
agreement: 87.4%  (95% CI 85.2% to 89.4%)
Cohen's kappa: 0.352  (95% CI 0.266 to 0.437)
a judge that always says 'stronger': agreement 85.0%, kappa 0

confusion matrix (rows: human, columns: judge)
            stronger    weaker
  stronger       817        19
    weaker       105        43

per label: precision = when the judge says it, how often the human agrees;
           recall    = when the human says it, how often the judge agrees
    stronger  precision  88.6%  recall  97.7%  (human 836, judge 922)
      weaker  precision  69.4%  recall  29.1%  (human 148, judge 62)
```

To gate CI, add thresholds. This fails (exit 1) when the lower end of kappa's CI is under 0.6, or when the judge catches under 80% of the failures your humans found:

```bash
judgeproof agreement labels.csv --min-kappa 0.6 --min-recall fail=0.8
```

Other options: `--group category` repeats the report per group, and `--json report.json` saves everything.

### 2. How many labels do you need?

With too few labels, kappa's confidence interval is too wide to tell a good judge from a bad one. Plan before you label:

```bash
judgeproof labels-needed --kappa 0.75 --minority 0.46      # balanced labels
judgeproof labels-needed --kappa 0.35 --minority 0.15      # a rare failure label
judgeproof labels-needed --pilot labels.csv                # from the labels you already have
```

```
  labels   median 95% CI width on kappa   (middle half of runs)
     100     0.26                           (0.25 to 0.28)
     200     0.18                           (0.17 to 0.20)
     400     0.13                           (0.12 to 0.13)

for a CI width of 0.20 (+/- 0.10): about 170 labels  (width ~= 2.60 / sqrt(n))
```

The rare-label case needs about 700 labels for the same width.

### 3. Did the judge see what it grades?

You need two files:

- **The agent run**, as OpenAI-style chat messages, the format most agent frameworks export.
- **What the judge received.** This is the request body your judge was sent (`.json`), or its rendered prompt (`.txt`).

```bash
judgeproof input check --run run.json --packet judge_request.json
```

```
Obligation 1: required content survives rendering (1 judge packet(s))
  [PASS] user message (step 1): present
  [FAIL] tool name 'lookup_order' (step 2): missing: 'lookup_order'
  [FAIL] arguments of 'lookup_order' (step 2): missing: 'HP-48213', 'ACCT-90517'
  [FAIL] result of 'lookup_order' (step 3): 0% of it
  ...
  [FAIL] blank step: step 2: assistant step with only tool calls reached the judge with none of them
Obligation 3: a failed check blocks later use
  BLOCK: 7 check(s) failed; exit 1 so the pipeline stops before using the judge
```

**No request log?** Do a dry run with `judgeproof capture`. It's a local fake judge that speaks the OpenAI API, saves every request it gets, and answers "pass". Point your eval tool's judge base URL at it:

```bash
judgeproof capture --port 8765 --out captures      # then use http://127.0.0.1:8765/my-tool/v1 as the judge's base URL
judgeproof input check --run run.json --packet captures/my-tool/0001-chat_completions.request.json
```

The checks follow the four input-assurance obligations in Xia et al., [*Does the Judge See What the Evaluation Requires?*](https://arxiv.org/abs/2611.02676) (2026):

| Obligation | Command |
|---|---|
| 1. Required content survives rendering | `input check` |
| 2. Each check covers what its criterion needs | `input check --spec spec.json` ([example](https://github.com/woqsi/judgeproof/blob/main/examples/five-tools/checker/example/spec.json)) |
| 3. A failed check blocks later use | exit code 1 |
| 4. The judge reads the same bytes that were checked | `input check --manifest m.json`, then `input verify --manifest m.json --packet sent.json` |

### 4. Does a pairwise judge prefer whichever answer comes first?

Run your pairwise judge twice per item, swapping the order. Record the winner by name (A, B or tie) both times:

```csv
id,verdict_ab,verdict_ba
q1,A,A
q2,A,B
```

```bash
judgeproof position-bias swaps.csv --max-flip-rate 0.1
```

This prints the flip rate with a CI, and how often the judge picked the answer shown first (50% means no preference). On MT-Bench, GPT-4's verdict changed on 15.8% of items when the answers swapped.

## In CI

Use the GitHub Action. It fails the step whenever judgeproof exits non-zero:

```yaml
- uses: woqsi/judgeproof@v0
  with:
    args: agreement evals/labels.csv --min-kappa 0.6 --min-recall fail=0.8
```

A full workflow is in [`examples/ci/judgeproof.yml`](https://github.com/woqsi/judgeproof/blob/main/examples/ci/judgeproof.yml). On any other CI, run `pip install judgeproof` and call the CLI. Exit codes:

| Code | Meaning |
|---|---|
| 0 | Passed |
| 1 | A check failed |
| 2 | Bad input |

## What it can't do

- **`input check` searches for text.** It can tell that the judge was shown the policy. It can't tell whether the judge understood it.
- **Agreement is only as good as your labels.** One labeler per item is noisier than a majority vote. Expect your numbers to sit closer to the per-vote figures in [examples/mt-bench](https://github.com/woqsi/judgeproof/blob/main/examples/mt-bench/RESULTS.md).
- **Small samples with a rare label give optimistic CIs.** Below about 100 labels with a label rarer than about 20%, a 95% CI covers the truth less often than 95% of the time. `labels-needed` warns you.

## Examples

| Folder | What it is |
|---|---|
| [`examples/mt-bench`](https://github.com/woqsi/judgeproof/tree/main/examples/mt-bench/) | A reproduction of the MT-Bench judge-agreement study: 12 of 12 published cells reproduced, the accuracy trap, labels needed, and position bias. The data is hash-checked, and one script rebuilds every number |
| [`examples/five-tools`](https://github.com/woqsi/judgeproof/tree/main/examples/five-tools/) | One agent run sent through DeepEval, Inspect, promptfoo, Opik and Phoenix, with the exact judge requests each tool sent. They double as ready-made fixtures for `input check` |
| [`examples/real-judge`](https://github.com/woqsi/judgeproof/tree/main/examples/real-judge/) | The follow-up: 40 agent runs graded by a real OpenAI judge, with and without the tool calls and with reasoning off and on, to see whether hiding them changes the grade |
| [`examples/ci`](https://github.com/woqsi/judgeproof/tree/main/examples/ci/) | A GitHub Actions workflow that gates on judge checks |

## Roadmap

We add checks as we test them. Planned next:

- captures from Langfuse and Braintrust
- judge drift between model versions
- more agent-run formats, such as OpenTelemetry GenAI spans

Ideas and bug reports are welcome in [issues](https://github.com/woqsi/judgeproof/issues).

## About

judgeproof is built and maintained by [Woq](https://woq.si), which helps AI teams build evals they can trust. MIT licensed.

If you use the MT-Bench example, cite the data: Zheng et al. 2023, *Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena* (CC-BY-4.0).
