Repository navigation
feat(tier3): add opt-in judge fallback and strict retry policies - #343
Merged
Merged
Conversation
LLM_JUDGE_FALLBACK_POLICY=replace lets only the judge model and the LLM_JUDGE_FALLBACK_MODELS entries answer a standard judge, without the built-in claude-opus-4-8 refusal fallback. LLM_JUDGE_RETRY_POLICY=strict tries at most three models with two requests each inside the per-judge time budget. It moves on only when a model is unavailable, ends the judge on a refusal or a quota, budget, billing, content-filter, safety or security error, and scores only a first completed reply that is exactly one JSON object, with no format retry, salvage or RAGAS request. An unknown value fails the standard judges before any request. Both variables are forwarded and staged like LLM_JUDGE_FALLBACK_MODELS, and run_config.json records a set value. The defaults keep today's behavior. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add a "Judge fallback and retry policies" section to the live evaluation guide, rows for LLM_JUDGE_FALLBACK_POLICY and LLM_JUDGE_RETRY_POLICY in the environment variable reference, the forwarding note in the custom graders guide, and a CHANGELOG entry under Unreleased > Added. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
commented
Nov 5, 2026
rng1995
left a comment
Collaborator
Author
There was a problem hiding this comment.
Automated review: 7 findings (0 P1, 2 P2, 5 P3); 6 posted inline.
Findings outside the diff or about the description:
prs/W70.md:32: P2: The PR text still has unfilled placeholders: 'TESTS_NEW tests' (line 32), 'FAIL_BEFORE' (line 40) and 'FULL_SUITE' (line 41). If this file is posted as the body of #343, it publishes template tokens instead of the test counts that the Tests section is supposed to state exactly.
Suggested fix: Fill in the measured values. tests/tier3/test_judge_policies.py has 59 tests. Fail-before (origin/main src, branch tests, scratch copy with the template swapped too): 41 failed, 18 passed. Full suite: rerun it and report the count, naming the local-only failures that also fail on origin/main (see 'checked'). The PR text file is at a local scratch script (line 32 is TESTS_NEW).
An unknown LLM_JUDGE_FALLBACK_POLICY value failed every standard judge before a request, except goal_accuracy on the OpenAI provider: the RAGAS scorer checked only the retry policy and sent its own request. RAGAS now stays off unless both policy values are known, so the prompt judge reports the configuration error instead. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The strict policy ended a judge whenever the error text contained a bare word such as safety, security, credit or budget anywhere, so an echoed model id (vendor/content-safety-judge) or a proxy host name in a connection error ended the judge instead of moving on. Stop reasons are now whole phrases (insufficient_quota, budget exceeded, credit balance, content_filter, blocked by a safety system, ...) matched only against what the provider said: the code, type and message of a JSON error body, the start of any other body, or a Bedrock error code and message. Connection errors never count. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The strict policy docs say a model the provider reports as not found, invalid or not accessible to the key moves on without a retry, but only the phrases the legacy fallback list recognizes did. OpenAI's real 404 (code model_not_found, "The model `x` does not exist ..."), a Claude not_found_error about the model, and Bedrock's AccessDeniedException, ResourceNotFoundException and invalid model identifier ValidationException all ended the judge. Under the strict policy these now move on to the next listed model without a retry. The legacy policy keeps its existing model error rules. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a later candidate ended a strict judge, only its own error was reported, so "primary 503 twice, then backup 401" read as an auth problem with the backup alone. The terminal error now lists every model's error in order, as the exhausted-fallback error already did. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A typo such as LLM_JUDGE_RETRY_POLICY=strcit was recorded in run_config.json as judge.retry_policy, as if it were applied, and the run spent the whole agent trial budget before every standard judge failed in the verifier. A run with standard grading now stops at configuration with the same message the verifier gives, and run_config.json records only a known value. custom_only runs, which never forward the policies, ignore them. The verifier keeps its fail-closed check. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two replace tests checked _fallback_models, which the policy does not change, so they passed without it. Replace them with an end-to-end check: a refused Claude 5.5 judge on Bedrock is answered by the LLM_JUDGE_FALLBACK_MODELS entry under replace, and by the built-in claude-opus-4-8 fallback under the default append. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
marked this pull request as ready for review
November 5, 2026 18:29
rng1995
requested review from
chrisknvidia,
mosheabr and
rmalani-nv
as code owners
November 5, 2026 18:29
src/skillevaluator/tier3/harbor/templates/eval.py: main rewrote _call_validated_json_judge to take metric and salvage keywords, record every attempt in judge_attempts.json, and send the named problem back in the retry, and behavior_check now goes through it. The merge keeps main's signature, body and docstring, adds the PR's sentence on the strict policy, and moves the PR's strict early return onto main's problem value. It returns after the first recorded attempt, before the retry and the salvage, with the message "Judge response was unparseable or invalid: <problem>; LLM_JUDGE_RETRY_POLICY=strict sends no retry". The default legacy policy keeps main's retry, salvage and error text unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The strict stop check read only the code, type and message fields of a
JSON error body, so a body without them, such as {"detail": "Budget has
been exceeded"}, was not checked at all. Read a detail field too, and
fall back to the body excerpt when a JSON body has none of these fields.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
No conflicts. main's Claude Code refusal-fallback switch (#337) adds one evaluator-managed runtime variable in harbor/adapter.py, apart from this PR's judge policy variables, and the CHANGELOG and docs entries sit side by side. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the main merges made on the PR branch on GitHub; no conflicts. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: CHANGELOG.md (kept main's new Added entry, then this PR's). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
enabled auto-merge (squash)
November 5, 2026 21:38
Collaborator
Author
|
Post-merge review: 1 finding(s) (P3). Follow-up PR: #359.
🤖 Generated with Claude Code |
7 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
append,legacy).LLM_JUDGE_FALLBACK_POLICY=replace: only the judge model and theLLM_JUDGE_FALLBACK_MODELSentries may answer. The built-inclaude-opus-4-8refusal fallback for Claude 5.5 or later judges is turned off: nofallbacksfield or beta header on the native Claude API, and no second Opus 4.8 request on Bedrock.LLM_JUDGE_RETRY_POLICY=strict:LLM_JUDGE_FALLBACK_MODELSentries) with at most two requests each, all inside the existing per-judge time budget. A schema downgrade or token refresh counts toward the two requests.Retry-Afterabove the maximum retry delay, or a model the provider reports as not found or not accessible. The last one moves on without a retry. It covers the errorsLLM_JUDGE_FALLBACK_MODELSalready falls back on, OpenAI'smodel_not_found, a Claudenot_found_errorthat names the model, and Bedrock'sAccessDeniedException,ResourceNotFoundExceptionand invalid model identifier errors.insufficient_quota,budget exceeded,credit balance,content_filter, ...) count, read from the code, type, message or detail of a JSON error body, the first 500 characters of any other body, or a Bedrock error code and message. A model id, a proxy host name or a connection error's text never ends the judge.NaN. An empty, invalid or truncated reply fails the judge without the format retry orbehavior_checksalvage, and another model is never asked to overturn it. The built-in refusal fallback and the RAGAS goal scorer (which sends its own requests) are off.custom_onlyruns ignore the variables. In the verifier, an unknown value still fails every standard judge before a request is sent, and keeps the RAGAS goal scorer off.LLM_JUDGE_FALLBACK_MODELSin the verifier judge controls, so they are forwarded and staged the same way: only to standard verifier jobs, never to the agent environment,runtime_envorcustom_onlyruns, and task-authored values are rejected.run_config.jsonrecords a known value asjudge.fallback_policy/judge.retry_policy.docs/tier3-live-evaluation.mdx, two rows indocs/environment-variables.mdx, and the forwarding note indocs/custom-graders.mdx. CHANGELOG entry under Unreleased > Added.Why
Some teams must control exactly which models score their skills, and how many times a judge is asked. Today a Claude 5.5 judge can be answered by
claude-opus-4-8even when the operator listed other fallbacks. A judge can also be retried up to four times per model, re-asked with a rewritten prompt after an invalid reply, and scored from JSON recovered from prose or a truncated reply. A refusal or empty reply moves on to the next model. These defaults suit most runs, but they let a different model or a later request overturn a completed answer. The strict policy gives a bounded, auditable alternative that fails closed instead.Kept from public
_call_judge_model, and both paths share it; the legacy loop keeps its fallback rules (refusal and empty reply move on,LLM_JUDGE_FALLBACK_MODELSonly on the model errors_should_try_fallbackrecognizes). The wider model-unavailable and stop-phrase rules apply only understrict._urlopen_with_retry, the Bedrock_converseloop,_is_retriable_http_status,_is_certificate_failure,_classify_bedrock_retry_error,_compute_bounded_retry_delay(maximum delay and judge deadline), the schema downgrade, and the per-judge budget and alarm in_call_required_judge. It only caps the requests per model and stops on the errors listed above._reject_duplicate_object_pairs,_reject_nonstandard_json_constant,_parse_finite_json_float) and the 128-level nesting bound.extract_jsonkeeps its permissive behavior by default.judge_model_used,judge_fallback_usedand the reasoning-effort record come from public's_record_judge_callon both paths.adapter.py(_VERIFIER_JUDGE_FALLBACK_ENV_VARS), so the existing staging, placeholder and rejection rules apply unchanged. The host check sits with the other configuration checks in_run_harbor_eval_impland uses its error and progress reporting.Tests
tests/tier3/test_judge_policies.py(85 tests):LLM_JUDGE_FALLBACK_MODELSentry underreplaceand byclaude-opus-4-8underappend; either policy drops the Anthropic server-side fallback and the Bedrock Opus 4.8 retry; the defaults (also" APPEND ",Legacy) keep themjudge_model_usedandjudge_fallback_used; at most three models, two requests each; 408/429/5xx, connection errors and Bedrock throttling move on after one retry; aRetry-Afterabove the maximum delay moves on, one past the deadline ends the judge; a schema downgrade counts as a requestmodel_not_foundand "does not exist", a Claudenot_found_errorfor the model,key_model_access_denied, and BedrockAccessDeniedException,ResourceNotFoundExceptionand an invalid model identifier move on without a retry; anothernot_found_errorand another BedrockValidationExceptionend the judgedetailfield or none of the usual fields; a stop phrase late in a long error page, a model id with "safety" in it, and a proxy host with "security" in it do not; the reason keeps the earlier models' errors (HTTP and Bedrock)NaNand invalid payloads fail without a second request; a whole object with surrounding whitespace keeps its verdict;behavior_checkneither retries nor salvages;goal_accuracyskips RAGAS; candidates share the judge deadline; legacyextract_jsonstays permissive, and the legacy loop keeps its model error rulescustom_onlyrun ignores them;run_config.jsondoes not record themverifier.envstaging, the host provider environment and the verifier job layer (notcustom_only),run_config.jsonrecording, and rejection from skillruntime_envtests/test_harbor_runner_environment.pyso the two names are forwarded from the host for each provider, andtests/test_harbor_runtime_skill_isolation.pyso they are rejected as task/step judge controls and accepted as exact operator-staged placeholders.src/(including the verifier template) frommainand this PR's tests,test_judge_policies.pyhas 61 failed and 24 passed. The 24 pin behavior this PR keeps:appendcase of the Bedrock refusal test, permissiveextract_json, and the legacy model error rulesmainfor that input: 400/401/403/409/501 end the judge (5), certificate failure,key_model_access_denied, anothernot_found_error, another BedrockValidationException, a model id with "safety" in it, the shared deadline, aRetry-Afterpast the deadline, and a whole-object verdict (2)custom_onlyignoring thempytest -n 8 tests): 21941 passed, 55 skipped, 19 failed. None of the failures is in code this PR touches:test_generated_custom_only_script_*intests/tier3/test_judge_failure_artifacts.pyalso fail onmainon this machine (the generated script stops with "unsupported operand type(s) for |"), and the 2test_sidecar_retains_*intests/test_harbor_secure_docker_environment.pyare known local-only failures onmaintest_local_callback_receives_complete_line_before_process_exit,test_bedrock_model_probe_classifies_malformed_local_sso_token_as_fatal[None-TypeError],test_slow_drip_request_line_and_headers_obey_an_absolute_deadline,test_bounded_harbor_process_timeout_preserves_redacted_diagnostic_tail) pass when rerun on the branchruff checkandruff format --checkare clean on the changed Python files, andscripts/check_oss_boundary.pypassed.🤖 Generated with Claude Code