Repository navigation
fix(tier3): turn off Claude Code's refusal model fallback in eval trials - #337
Merged
Merged
Conversation
When the model provider's safety classifier stops the selected model, Claude Code 2.1.292 retries the turn on another model from its own fixed table (for example claude-opus-4-8 after Claude Opus 5.5) under that bare Anthropic model ID. A route that does not serve the ID, such as a gateway that serves only the selected model, answers HTTP 403 and Harbor records UnknownApiError. Where the retry succeeds, the trial finishes on another model but is scored as the selected one. Add CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=1 to the evaluator-managed task environment that every generated and native task writes into [environment.env], next to CLAUDE_CODE_DISABLE_BACKGROUND_TASKS. Harbor applies it in every env mode and on every provider route. The managed value is merged last, so a native task cannot set it back, and harbor.runtime_env already rejects CLAUDE_CODE_* names. Other agents ignore the variable. With the fallback off, the CLI stops with model_refusal_no_fallback and Harbor 0.24's own Claude Code classifier raises AgentSafetyRefusalError. Tests pin that classification for Harbor's ClaudeCode and the container and local wrappers, including that refusal text in tool output is not a refusal. Scoring is unchanged: the refused attempt is an unscored trial failure that counts against scored-attempt coverage. Document the behavior and add a troubleshooting entry. 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 17:06
rng1995
requested review from
chrisknvidia,
mosheabr and
rmalani-nv
as code owners
November 5, 2026 17:06
rng1995
commented
Nov 5, 2026
rng1995
left a comment
Collaborator
Author
There was a problem hiding this comment.
Automated review: 3 findings (0 P1, 0 P2, 3 P3); 3 posted inline.
The Harbor pins classified a hand-written launch command. Harbor 0.24's Claude Code classifier reads only the CLI's terminal events when the command contains --output-format=stream-json, and scans all of stdout otherwise. A Harbor upgrade that changed its real launch would leave the pins green while refusal text in tool output became a safety refusal again. The pins now run the real run() of Harbor's ClaudeCode, the container and local wrappers, and the container wrapper on the Vertex AI route, against a Harbor environment stub that fails the launch the agent builds. A new case ends the stream with a max-turns result that matches no Harbor pattern, so the only refusal text is in tool output and model text; it fails if the stream-json filter stops applying. The 529 case alone could not show that, because the last match in stdout wins. The launch tests also check that the staged switch reaches the launch environment on every lane, including after the Vertex AI wrapper filters the agent's variables. The provider-route test gains a Vertex AI route (GKE mode, Workload Identity, explicit Claude model), and each route asserts a credential name its plan stages. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Code CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK was checked with Claude Code 2.1.292, the release Harbor installs. Local mode runs the Claude Code already on the host, which may be any release from 2.1.280 for Claude 5.5 models. The docs said one model answers the whole trial in every env mode. Say that the behavior holds for the pinned release, and that local mode keeps the fallback off only if the host's Claude Code honors the variable. The CHANGELOG entry says the same. A test ties the docs paragraph to the pinned version, so a Claude Code pin bump has to re-check the variable and update it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the CHANGELOG.md conflict: keep main's PII entry (#304) and add this PR's refusal-fallback entry after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/agents-and-sandboxes.mdx and the adapter comment said that, with the fallback off, one model answers the whole trial. The switch only stops Claude Code's refusal retry. Harbor pins Claude Code's Haiku and subagent model aliases to the selected model only on routes that set ANTHROPIC_BASE_URL, so on the Anthropic API, Bedrock and Vertex AI routes helper and subagent calls can still use another model. Both now say a refused turn is not retried on another model. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
enabled auto-merge (squash)
November 5, 2026 18:28
rng1995
added a commit
that referenced
this pull request
Nov 5, 2026
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]>
rng1995
added a commit
that referenced
this pull request
Nov 5, 2026
…age (#347) The CHANGELOG entry, the Supported agents paragraph and the Troubleshooting entry for the Claude Code refusal switch (#337) said only that a refused attempt counts against scored-attempt coverage. They now name the visible result: the arm reports an incomplete coverage line such as `Scored attempt coverage is 59/60`, its execution fails, and `tier3 evaluate` and `validate --block-on-agent-eval` exit 1. On a route that serves the fallback model, a run that completed before can now fail. A new test checks the coverage message and that the docs state it. Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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
CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=1to the evaluator-managed task environment (_EVALUATOR_MANAGED_RUNTIME_ENVintier3/harbor/adapter.py), next toCLAUDE_CODE_DISABLE_BACKGROUND_TASKSfrom fix(tier3): disable Claude Code background tasks in eval trials #268.[environment.env], so Harbor applies it to the agent in every env mode, including local mode, and on every provider route, Vertex AI included.[environment.env]cannot set it back.harbor.runtime_envalready rejectsCLAUDE_CODE_*names. Other agents ignore the variable.model_refusal_no_fallback, and Harbor 0.24's own Claude Code classifier raises its typedAgentSafetyRefusalError. No SkillEvaluator classifier change is needed.docs/agents-and-sandboxes.mdx(Supported agents) and adds a Troubleshooting entry forAgentSafetyRefusalErrorindocs/tier3-live-evaluation.mdx. The docs and the CHANGELOG entry (Unreleased > Fixed) say the variable was checked with the pinned Claude Code 2.1.292, and that local mode keeps the fallback off only if the host's Claude Code honors it.Why
When the model provider's safety classifier stops the selected model, Claude Code 2.1.292 (the version Harbor installs) retries the turn on another model from its own fixed table, for example
claude-opus-4-8after Claude Opus 5.5. It sends that bare Anthropic model ID, and nothing in SkillEvaluator maps it.UnknownApiError, and the attempt reads as a broken credential or API, not as a refusal.With the fallback off, the pinned Claude Code does not retry a refused turn on another model, and a refusal is reported as a refusal. A scratch run on
mainshows the switch is missing from staged tasks, and that Harbor reads the fallback's 403 stream asUnknownApiErrorbut the no-fallback stream asAgentSafetyRefusalError.The refused attempt is still not scored, like any other failed trial, and counts against the arm's scored-attempt coverage. This PR does not change how a refusal is scored or counted.
Kept from public
_EVALUATOR_MANAGED_RUNTIME_ENV, merged last into generated and native tasks) is reused as is. No per-agent environment or extra Harbor--aeargument is added.ClaudeCode._classify_exec_erroris kept. It reads only the CLI'sresultanderrorevents of its own stream-json launch and uses high-precision refusal patterns, so refusal text in tool output or model replies does not become a refusal. New tests run each Claude Code agent's real launch through it, so a Harbor upgrade that changes the launch or the filter fails them.AgentSafetyRefusalErroras an ordinary trial failure, not an agent-runtime or infrastructure failure (pinned bytests/test_harbor_collector_runtime_failures.py). Scoring, coverage and lift are unchanged.ANTHROPIC_API_KEY,ANTHROPIC_BASE_URLandCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS(pinned bytests/test_gateway_defaults.py). The fallback model is not mapped or rerouted.installed_agents.pyandlocal_agents.pyare not changed.Tests
tests/test_harbor_claude_refusal_fallback.py(32 tests) with stream fixtures intests/claude_refusal_fixtures.py:harbor.runtime_envcannot turn it off (rejected, and the staged task still has1)[environment.env]cannot turn it off1to the agent command over a host value of0(POSIX only, like the fix(tier3): disable Claude Code background tasks in eval trials #268 test)run()of Harbor'sClaudeCode, the container and local wrappers, and the container wrapper on the Vertex AI route. A stub Harbor environment uses Harbor's own task and exec environment merging and fails the launch command the agent builds. On each of the 4 lanes: the staged switch reaches the launch environment (on Vertex AI, after the wrapper filters the agent's variables); the no-fallback stream givesAgentSafetyRefusalError; the fallback 403 stream givesUnknownApiError; refusal text in tool output and model text givesApiOverloadedErrorwhen a 529 ends the stream, and a plainNonZeroAgentExitCodeErrorwhen a max-turns result that matches no Harbor pattern ends it.main: every task-environment test, the 4 launch-environment tests and the docs test. The 17 Harbor classification and redaction tests pass on both, as expected.--output-format stream-jsonin a scratch run, Harbor scanned all of stdout, and the 4 max-turns tests failed withAgentSafetyRefusalError. The 529 case stays green either way, because the last match in stdout wins.tests/test_ci_workflows.py,tests/test_gateway_defaults.pyandtests/test_harbor_collector_runtime_failures.py(59 modules): 4313 passed, 8 skipped, 15 failed. All 15 fail the same way onmainon the test host: 2tests/test_harbor_secure_docker_environment.pysidecar Compose tests, and 13tests/tier3/test_judge_failure_artifacts.pycustom-only script tests that run the host's Python 3.9python3, which cannot evaluateint | float.ruff checkandruff format --checkare clean on the changed Python files.scripts/check_oss_boundary.pypassed.🤖 Generated with Claude Code