Skip to content

fix(tier1): retry an invalid rubric judge reply once and name the problem - #415

Merged
chrisknvidia merged 8 commits into
mainfrom
naren/port-tier1-rubric-invalid-reply-retry
Nov 13, 2026
Merged

chrisknvidia merged 8 commits into
mainfrom
naren/port-tier1-rubric-invalid-reply-retry

Conversation

@rng1995

@rng1995 rng1995 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • RubricJudge.process now checks the judge's reply before returning it. When json cannot parse the reply (a JSONDecodeError, or the plain ValueError or RecursionError that json.loads raises for an integer past the digit limit or nesting too deep), or its checks fail _normalize_rubric_checks (a missing, repeated or unknown criterion, a score outside 0 to 10, a pass flag that is not a boolean, an empty or non-list checks), it asks the judge once more: the same system prompt and user prompt, plus YOUR PREVIOUS REPLY WAS REJECTED: <problem>. Reply again with ONLY one JSON object in the shape described above.
  • The reply is checked against the criteria passed to process (criteria=, which create_user_prompt already honors), or RUBRIC_CRITERIA when none are given. _normalize_rubric_checks takes an optional criteria argument for this; the validator still calls it with the default.
  • The log line and the retry note keep the first 500 characters of the problem, followed by ... [truncated]. The problem can quote the judge's own text, such as an invented criterion id of any length. The finding still carries the full text, as on main.
  • The second reply is returned as parsed, unchanged. If it is still invalid, today's paths apply: a HIGH llm_invalid_response finding, or llm_unavailable when it is still not JSON.
  • The LLM client still retries a transient provider error (a rate limit or a server error) inside each request, as set by SKILL_EVAL_LLM_MAX_RETRIES. A request that still fails after those retries, a refusal, an empty reply and a truncated reply are not asked again: they return the fallback with last_failure set, as in LLMClient.process. A truncated reply is never salvaged.
  • Both requests use the class response_schema, schema_name and reasoning budget, as today.
  • The JSON report records judge_attempts, the number of times rubric-eval asked the judge (1, or 2 after a rejected reply), in the skill's rubric_eval success detail or llm_* finding and, for a single skill, in the rubric_eval object. The client's own retries are not counted. When the first request fails, for example because no provider is configured, no reply came back and judge_attempts is left out. Folder runs keep one count per skill.
  • Docs: two paragraphs in the rubric-eval accordion of docs/tier1-validation.mdx. CHANGELOG entry under Unreleased > Fixed.
  • Open PRs fix(tier1): scope ownership email policy and retain completeness diagnostics #333 and feat(quality): configure Reliability error handling in the quality config #336 also edit docs/tier1-validation.mdx. This PR's hunk stays inside the rubric-eval accordion, apart from theirs. Open PR feat(tier3): add fixed-source skill interaction evaluation #392 also edits tests/inference/test_llm_client.py; its hunks (import httpx above import pytest, the endpoint test near line 199) are apart from this PR's (the constants import, the Claude 5.5 rubric test near line 1073), and that file merges with feat(tier3): add fixed-source skill interaction evaluation #392 with no conflicts. No open PR touches rubric_eval.py.

Why

Rubric evaluation runs in Tier 1 whenever a provider is configured. RUBRIC_JSON_SCHEMA does not constrain criterion ids, so a reply can still skip, repeat or invent a criterion, and some providers ignore the schema. On main, RubricJudge inherits LLMClient.process, which sends one request. The first reply that misses a criterion becomes a HIGH llm_invalid_response finding, and HIGH always fails Tier 1, so the user has to rerun. A reply in prose becomes llm_unavailable. One retry that names the problem usually recovers.

Reproduced on main with a scripted judge (first reply missing error_handling_quality, then a valid reply): 1 request and LLM judge returned invalid rubric evidence: missing criterion ids: error_handling_quality. On this branch: 2 requests, scored 80.0, passed.

Kept from public

  • The checks-list reply contract, RUBRIC_JSON_SCHEMA, the system and user prompts, and _extract_json are unchanged. The retry reuses _normalize_rubric_checks for the problem text, so the judge sees the same message the finding would show, cut to 500 characters.
  • Scoring stays local: _aggregate_rubric_score, the 7-point criterion threshold, the all-criteria-pass gate, judge_pass and the judge's own score / overall_pass as diagnostics.
  • Fail-closed results stay: a second invalid reply is still a HIGH finding, and an unavailable judge is still a HIGH llm_unavailable finding, never a skipped rubric or a 0/100 score.
  • The client's transient-error retries, schema downgrade and Anthropic server-side fallback are unchanged.
  • Model provenance is unchanged: llm_provider and llm_model_used name the model that answered the request that was scored, which after a retry is the second request.
  • salvage_truncated_response stays off for the rubric judge.

Tests

  • tests/validators/test_rubric_eval.py: 27 new tests in TestInvalidReplyRetry:
    • an invalid first reply is retried once and then scored, for 8 kinds of reply (missing, duplicate and unexpected criterion, score 11, non-boolean pass, empty checks, prose, unclosed JSON). The retry prompt is the first prompt plus the problem, both requests carry the rubric schema, the score is computed locally (90.0 while the judge said 0), there is no llm_* finding, and judge_attempts is 2 in the rubric_eval object and the success detail
    • a reply that json.loads rejects with a plain ValueError (an integer one digit past the interpreter's limit) or a RecursionError (with a message, and without one) is retried once with the parser's message, or RecursionError when there is none, and then scored (3 cases). A stand-in parser raises the RecursionError, because the nesting depth that triggers it differs by Python version and platform. The ValueError case is skipped on an interpreter with no digit limit
    • a valid first reply sends one request and records judge_attempts 1
    • a second invalid reply fails closed with HIGH llm_invalid_response naming the second reply's problem (2 cases), and a second unparseable reply reports llm_unavailable
    • a request error, a refusal and a truncated reply (whose content is a complete reply) send one request, report llm_unavailable with their diagnostic and record no judge_attempts (3 cases); a refusal on the retry reports llm_unavailable with judge_attempts 2
    • with no provider configured, no client is created, and the JSON report has an llm_unavailable finding and no judge_attempts
    • through the Anthropic SDK with a mocked transport, a 503 that the client retries and then a valid reply make 2 HTTP requests and judge_attempts 1
    • a reply that invents a 20,000-character criterion id gets a retry note and a log line with the first 500 characters of the problem plus ... [truncated]
    • with custom criteria=, a correct reply sends one request, and a reply missing a custom criterion is retried with a note that names it and no default criterion (2 cases)
    • the judge returns the second reply as parsed and clears a stale last_failure
    • a three-skill folder keeps each skill's count (2, 1, and 2 on the failing skill's finding)
    • through the Anthropic SDK with a mocked transport, the retry request carries the problem and the same output_config format, and the report names the model that answered the retry
  • tests/inference/test_llm_client.py: test_claude_5_5_rubric_gets_schema_effort_and_server_side_fallback now mocks a complete rubric reply, checks that exactly one request is sent and still checks its schema, effort and server-side fallback options.
  • Fail-before: with src/ from main (d717f22) and this PR's tests, test_rubric_eval.py has 22 failed, 97 passed, 1 skipped. 22 of the 27 new tests fail, on the request count, the result or the new judge_attempts field. The other 5 (the 3 provider errors, no provider, and a correct custom-criteria reply) send the same single request as main, which records no count.
  • tests/validators/test_rubric_eval.py: 119 passed, 1 skipped.
  • That module plus tests/inference/test_llm_client.py, tests/test_publication_evidence.py, tests/reporting/test_reporters.py, tests/reporting/test_rich_markup_escaping.py, tests/cli/test_tier_workflows.py, tests/test_commands.py, tests/test_cli.py, tests/validators/test_markdown.py, tests/test_ci_workflows.py, tests/ci/test_image_build.py, tests/test_ci_change_classifier.py, tests/test_oss_packaging.py, tests/test_harbor_claude_refusal_fallback.py, tests/tier3/test_private_loose_source.py and tests/test_benchmark_rollout_docs.py: 1193 passed, 1 skipped.
  • The branch now includes main at d717f22. That merge conflicted only in CHANGELOG.md, where both Unreleased > Fixed entries are kept. The counts above are on the merged branch.
  • ruff check and ruff format --check are clean on the changed Python files, and scripts/check_oss_boundary.py passes.

🤖 Generated with Claude Code

rng1995 and others added 3 commits November 7, 2026 20:34
…blem

A rubric judge reply that is not valid JSON, or whose checks miss, repeat
or invent a criterion or carry an out-of-range score or a non-boolean pass
flag, used to end rubric-eval with a HIGH llm_invalid_response or
llm_unavailable finding after a single request, which fails Tier 1.

RubricJudge.process now sends the request once more with the original
prompts plus the problem found by _normalize_rubric_checks (or the JSON
parse error), and returns the second reply as parsed so the validator's
fail-closed paths still apply to it. Provider errors (failed requests,
refusals, truncated replies) are not retried and keep last_failure and the
fallback of LLMClient.process. The number of requests is recorded as
judge_attempts in the rubric_eval metadata, the success detail and the
llm_* finding.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the retry note

- judge_attempts now counts the times rubric-eval asked the judge (1, or 2
  after a rejected reply). It is left out when the first request fails, so a
  run with no provider no longer reports 1 next to "did not run". The LLM
  client's own transient-error retries are not counted.
- The retry check validates the reply against the criteria passed to
  RubricJudge.process, not always the default rubric, so a correct reply to
  custom criteria is not sent again.
- The log line and the retry note keep the first 500 characters of the
  problem. A reply that invents one very long criterion id no longer slows
  the warning or sends that id back to the model in full.
- Docs and CHANGELOG say that the client still retries transient provider
  errors (SKILL_EVAL_LLM_MAX_RETRIES) and that only a request that still
  fails, a refusal or a truncated reply is not asked again.
- The Claude 5.5 rubric request test mocks a complete reply and checks that
  one request is sent.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The retry caught only json.JSONDecodeError, so a first reply that
json.loads rejects with a plain ValueError (an integer past the digit
limit) or a RecursionError (nesting too deep) skipped the retry and
ended as llm_unavailable after one request. Catch both; the problem
text for a JSONDecodeError is unchanged.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 marked this pull request as ready for review November 9, 2026 19:49
Bring the branch up to date with public main (d717f22).

Conflicts:
- CHANGELOG.md: both sides appended an entry at the end of Unreleased >
  Fixed, after the HTTPie network-exfiltration entry. Kept main's
  `tier3 compare` Overall lift entry and placed this branch's
  `rubric-eval` retry entry after it. No released section changed.

docs/tier1-validation.mdx merged cleanly: main added the "Tier 1 in
automatic CI" section near the top, and this branch's two paragraphs stay
inside the rubric-eval accordion.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review found a credential-handling issue in the new retry diagnostic; fixing with a regression test.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full production diff and rubric/provider/error-handling callers. Fixed the inline credential-leak finding in 8558454: sanitize judge-supplied rejection text before logging or truncation, with two regression cases (both failed before the fix). All 29 retry-contract tests pass under locked dependencies; full src/tests Ruff lint and formatting of changed Python files pass. Current main ce52a09 merged without conflicts and the signed-off fix was pushed normally. Broader pre-existing rubric/client selection was interrupted during slow filesystem fixtures, without claiming a completed full-suite run. No remaining actionable finding; PR remains open and unmerged.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The published-docs audit found a broken link introduced here; fixing the site URL.

Comment thread docs/tier1-validation.mdx Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final follow-up: fixed the published environment-variable link in rubric retry guidance and resolved its inline thread. Pinned Fern5.121 check passes with 0errors and 1existing configuration warning. The credential-redaction fix and its previously passing 29 retry-contract tests remain unchanged; the documentation follow-up was signed off and pushed normally. Both inline findings are addressed. Open and unmerged.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved new-main CHANGELOG conflicts while retaining the rubric, credential-redaction, docs and upstream entries. Against main a0b65a9: 29 retry contracts pass, full src/tests Ruff lint passes, and pinned Fern check has 0 errors/1 existing warning. PR was still open and the latest-main merge check was clean before the signed-off normal push.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current-head integration review: reconciled the actual CHANGELOG-only conflict with main b38b71b, preserving all entries and placing the complete rubric retry entry and both review-fix notes after the assigned stable anchor. The reviewed credential redaction and published documentation link remain intact. Verification on this head: 29 invalid-reply retry contracts passed, Ruff src/tests passed, and Fern check found 0 errors (1 existing warning). Fresh pre-push open/head/base/main checks and both merge-tree checks passed. No PR merge performed.

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I checked the retry path in RubricJudge.process: a parse error (including the plain ValueError and RecursionError cases) or a _normalize_rubric_checks problem gets exactly one more request, and the second reply goes back through the same validation, so a second bad reply still fails closed as HIGH. Request errors, refusals and truncated replies are not retried, last_failure is reset on each call, and judge_attempts is left out when no reply came back. The problem text is redacted and capped before it goes into the log line and the retry prompt. The 320 rubric/LLM-client tests pass and ruff is clean.

@chrisknvidia
chrisknvidia merged commit 4afd3d0 into main Nov 13, 2026
27 checks passed
@chrisknvidia
chrisknvidia deleted the naren/port-tier1-rubric-invalid-reply-retry branch November 13, 2026 06:05

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this after it merged, so treat what follows as follow-ups.

I read the full src diff, ran test_rubric_eval.py and the touched client test locally (all pass; 24 of the new tests fail against main's src), and probed the retry with scripted replies. The code does what it says. The only change I need before merge is in the CHANGELOG.

What I checked. The judge is asked exactly once more: last_attempts is set to 2 before the second request and the second reply is never re-checked in process(), so there is no third ask (the tests script exactly two replies, so a third would fail them). A refusal, a truncated reply, an empty reply or a request that still fails after the client's own retries goes to the same fallback as before, so it is not asked again and reports llm_unavailable with the diagnostic; truncated replies are never salvaged. If the second reply is also invalid it is returned as parsed and validate() re-checks it with the same default criteria, so it ends as a HIGH llm_invalid_response (or llm_unavailable when it is not JSON). Nothing silently passes or gets a score, and a first reply that process() accepts is always one the validator accepts. A valid first reply sends one request and returns the same dict as before. There is no token or cost accounting in this path to update; judge_attempts counts asks, not the client's retries. The retry note for a parse failure uses the JSON error text, which does not quote the reply, and the note built from the checks is redacted before it is cut to 500 characters. Redaction does not mangle legitimate problem text (the longest possible missing-ids message is 256 characters), and it stays fast on 200 KB adversarial input (under 0.3 s each).

To fix: CHANGELOG.md has two extra one-line bullets about the redaction and the docs link. Those are fixes to the retry feature in the entry above, which has not been released, so please fold them in or drop them.

Not blocking: the second-failure finding message and rubric_eval.summary still carry the raw, full-length validation_error (a secret-looking id shows as sk- in the log but in full in the report); control characters are not stripped from the retry note; and process() copies LLMClient.process, which will drift. Details are in the inline comments.

Comment thread CHANGELOG.md Resolved
@rng1995

rng1995 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

Post-merge follow-up: #484 addresses the final-report rejection diagnostic exposure, single-line retry/final diagnostic controls and unreleased-changelog cleanup from this review. Nine new regression cases failed before the fix; 130 rubric tests pass with 1 skip, full src/tests Ruff passes, and independent review approved the candidate. The shared-client extraction suggestion has a technical disposition in its inline thread. #484 is ready for review and not yet merged; no closed branch was edited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants