Repository navigation
chore(evals): grade a judge reply only when its verdict is unambiguous, retry once, and keep the reply - #839
Conversation
…eply without one, and keep it in full The Claude judge provider required the verdict to be the reply's last JSON object, so replies that opened with a passing verdict were recorded as graderError and aborted the run (#796). - The verdict is now the reply's one top-level object with a "pass" key, wherever it sits; objects and prose around it are ignored. Raw control characters inside a string decode. Two different verdicts are an error. - A judge reply with no valid verdict is asked once more. When the second has none either, both replies are written in full, redacted, to tests/evals/results/judge-replies/ (gitignored) and the error names the file next to the 400-character excerpt. - A valid first reply reaches promptfoo unchanged, after one call. - Tests run on real judge replies (tests/fixtures/judge_replies.json) in each failure shape the recorded excerpts point at. Rubrics, thresholds and the judge prompt are unchanged. Closes #796
…ested inside it
A verdict-shaped object that does not decode (truncated, a trailing comma,
unescaped quotes in the reason) is now a "malformed verdict object" error, so
the scan never grades a {"pass": true} nested inside a broken FAIL verdict.
Duplicate verdicts are compared as JSON text, so "pass": 1 never merges with
"pass": true. Kept replies are redacted per string before json.dumps (a
Windows home path is now scrubbed), the kept path names home as ~, the secret
list covers the bare-secret shapes feedback_memory refuses plus github_pat_,
and an error after spent calls carries their tokenUsage and cost.
A failed-decode `{` that opens a quoted key is refused whatever its first
key; the rubric's format template (a <placeholder> first value) and prose
braces are skipped. Verdicts dedupe by equality with the pass type kept,
errors and excerpts are redacted, home is redacted only as a whole path,
a PEM private-key block is redacted, and a failed call's reported usage
is counted.
Replace the first-key guessing for undecodable objects with one rule: every "pass" key in the reply, other than the rubric's format template, must lie inside a decoded top-level object, else the reply is a malformed verdict and is asked again. Undecodable braces without a pass key (a quoted Python dict, a JS snippet) are skipped. Dedupe verdicts on a canonical JSON form that merges 1 and 1.0 but keeps types apart at every depth. Redact CLI output before the excerpt cut and before repr, and redact home before punctuation but not inside another path.
An object that opens with a quoted key but does not decode now spans to its closing brace, counted outside quoted strings, or to the end of the reply. A verdict or a "pass" key inside that span refuses the reply; a "pass" key in prose outside every such span is ignored, and the format template is matched tolerantly by its own span. The home redaction keeps `/Users/al.smith` intact.
Replace the failed-brace range scanner with a fail-closed rule. A judge reply is graded only when its decoded verdict objects are all the same verdict, none is the value of a quoted key, every "pass" key sits inside that verdict or the rubric's exact format template, and no quoted-key object fails to decode. Anything else is retried once and then kept as an error, never graded from a guess.
An unescaped quote lets raw_decode accept a short prefix of a broken object, after which a nested verdict decoded as if it were top level. Any decoded object followed by a comma, quote, colon, closing brace or bracket was cut out of a larger structure, so the reply is refused.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54f51bf217
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge-readiness evidence, head
|
| # | behaviour | observed | met |
|---|---|---|---|
| 1 | real judge replies grade normally through the changed provider | final head a9755282, real Claude pair (haiku candidate, claude-opus-5-5 judge) on skill-deciding-approach.yaml (5/5) and skill-implementing-with-tdd.yaml (6/7; the one fail is a deterministic candidate assertion, the judge passed it at 0.85): 12 judge calls, 0 judge errors, 0 retries, 0 kept-reply files; every graded pass matches its "Verdict" word. An earlier head (54f51bf2) also ran three configs, 13 judge calls, 0 errors |
yes |
| 2 | a reply with no verdict is retried exactly once, then errors | provider call_api with a stub claude: two calls, then judge reply has no verdict object ... (asked twice; both replies kept at ~/.../judge-reply-<id>.json) |
yes |
| 3 | the terminal error keeps the full redacted reply and a concise excerpt | kept file holds both replies whole, planted token and home path redacted; console excerpt names the file | yes |
| 4 | conflicting / contradicting / duplicate-key replies are errors | each made 2 calls and errored; origin/main's provider graded all three silently |
yes |
| 5 | valid replies byte-compatible at the provider boundary | the three real fixture verdicts return identical dicts from this head and origin/main |
yes |
| 6 | no rubric, threshold or candidate output loosened | only the provider, its README, its test and the fixture changed; no yaml | yes |
Acceptance criteria (#796): 2-7 met. AC1 ("real failing replies captured as redacted fixtures") is met only as real replies plus the failure shapes reconstructed from the surviving 400-character excerpts: the original failing replies were never stored in full. The new kept-reply file captures the full reply next time.
🤖 I have created a release *beep* *boop* --- ## [0.74.0](v0.73.1...v0.74.0) (2026-10-04) ### Features * **installer:** save the MCP tool profile once for every launch path ([#836](#836)) ([b9215a8](b9215a8)) * **release:** ship SBOM, build provenance and digests, and pin every action to a commit SHA ([#838](#838)) ([df310e6](df310e6)) ### Miscellaneous Chores * **evals:** grade a judge reply only when its verdict is unambiguous, retry once, and keep the reply ([#839](#839)) ([237ea59](237ea59)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
Summary
The Claude judge provider required the verdict to be the reply's last JSON object, so valid judge replies (a verdict followed by notes, prose with braces, a repeated verdict) aborted eval runs. It now finds the reply's one verdict wherever it sits, grades it only when it is unambiguous, retries a reply without a usable verdict exactly once, and keeps the full redacted reply when it still fails. The rule is fail-closed: a doubtful reply is asked again and then errors with the reply kept for diagnosis; it is never graded from a guess.
Related issue
Closes #796
Changes
tests/evals/promptfoo/providers/claude_cli.py:"pass") exists, everypasskey in the reply (any spelling, quoting or case) belongs to that verdict, no quoted-key object fails to decode, no decoded object was cut out of a larger structure, no key repeats, no nestedpassdisagrees with the top-level one, and no stated grade contradictspass("Verdict PASS"/"VERDICT: FAIL" on the same line, uppercase, pastis/was/ofand punctuation; averdict/passed/resultstring). Only the rubric's exact format template is exempt. Repeats of the same verdict still grade.tests/evals/results/judge-replies/(gitignored) with secrets (sk-, GitHub tokens, AWS keys, Slack tokens, JWTs, PEM blocks, credential assignments such aspassword=,client_secret:,Authorization: Bearer) and the home directory (either separator form) redacted before encoding; the console error keeps a redacted 400-character excerpt and names the file.tests/fixtures/judge_replies.json: real judge replies (two passes, one fail, one no-verdict answer) used as fixtures in five shapes each.tests/test_claude_cli_provider.py: graded and refused cases for every rule above, retry and usage accounting, redaction, and the kept-reply file.tests/evals/promptfoo/README.md: the rule in plain words and its trade-off.Rubrics, thresholds and
claude-judge.yamlare unchanged.Drift from the issue text: the replies that originally failed were never stored in full (only 400-character excerpts survive), so AC1's "real failing replies" are real replies plus the failure shapes built from those excerpts; the new kept-reply file captures the full reply next time. The judge prompt (in the issue's scope) is unchanged: no captured reply shows what it should say differently, and any change would move every grade.
How it was verified
tests/test_claude_cli_provider.py: 222 passed; every captured fixture shape grades and equals itsjson.loadsvalue;origin/main's parser errors on the trailing-object and raw-newline shapes of all three real verdicts.a9755282): all 28 checks green incl. Windows; mutation gate run 37202525282 green (0 survivors); pre-push full suite 5633 passed at 100% coverage.skill-deciding-approach.yaml5/5 andskill-implementing-with-tdd.yaml6/7 (the one fail is a deterministic candidate assertion), 12 judge calls, 0 judge errors, 0 retries, every gradedpassmatching its stated verdict word. Retry, kept-reply and contradiction behaviour checked throughcall_apiwith a stub CLI (full ledger in the proof comment)./code-reviewhigh on the whole diff, then on every fix delta. After six rounds of heuristics each opened new silent-pass cases, the parser was rewritten fail-closed (your decision); the following rounds closed duplicate keys, variant pass keys, cut-out objects, nested and stated-verdict contradictions.Not changed, noted for later (accepted residuals, none graded differently from
origin/main, which ignores everything but the last object):reason, and a booleanresultkey.*pass*:,pass is false,pass -> false).scorethat contradictspass(promptfoo applies thresholds).,,"or:is retried and may error./c/Users/...) form are not redacted; a bareBearer <token>without a key is not redacted; a few labels ("Tokens: 1200") lose their first value word.Checklist
pytest) and lint/type checks are green (pre-commit run --all-files,python -m mypy)