Repository navigation
fix(tier3): disable Claude Code background tasks in eval trials - #268
Merged
Merged
Conversation
A claude-code trial could answer and still never finish. Claude Code moves a shell command that outlasts its Bash timeout to the background (or runs it there on request), and a headless --print run waits for background commands before it exits. A command that never ends, such as an agent's `grep -r /` search for a skill that is not installed, therefore held Harbor's `claude ... --print | tee` pipeline open after the final answer. The trial ran to the agent timeout and the case was recorded as an unscored agent timeout. Reproduced with Claude Code 2.1.293 for both an explicit run_in_background call and a foreground command that hit the Bash timeout. Add CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 to the evaluator-managed task environment that every generated and native task writes into [environment.env]. Harbor applies it to agent commands in every env mode, for stock claude-code and the SkillEvaluator wrappers alike. Claude Code then drops run_in_background and stops a long command at its Bash timeout instead of backgrounding it. 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. Document the behavior and how a skill can raise Claude Code's per-command default with BASH_DEFAULT_TIMEOUT_MS in harbor.runtime_env. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
requested review from
chrisknvidia,
mosheabr and
rmalani-nv
as code owners
October 30, 2026 18:54
rng1995
commented
Oct 30, 2026
rng1995
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review of #268: no findings.
Checked: the new env var is injected via _EVALUATOR_MANAGED_RUNTIME_ENV, which is merged last for both generated and native task paths, so neither harbor.runtime_env nor a native [environment.env] can override it; the local-mode test confirms the host value cannot leak through. CHANGELOG entry is under Unreleased/Fixed and docs match the behavior (BASH_DEFAULT_TIMEOUT_MS escape hatch, agent timeout bound).
Local results: tests/test_harbor_claude_background_tasks.py 5 passed; ruff check clean; ruff format clean on the changed files.
Reviewed with Claude Code.
chrisknvidia
force-pushed
the
naren/port-claude-disable-background-tasks
branch
from
October 30, 2026 22:25
b6ff5a6 to
e44d872
Compare
This was referenced Nov 2, 2026
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_BACKGROUND_TASKS=1is added to_EVALUATOR_MANAGED_RUNTIME_ENVintier3/harbor/adapter.py. Every generated and native task already writes that mapping into[environment.env], which Harbor applies to agent commands in every env mode. The change is one entry plus a comment.run_in_backgroundfrom its Bash tool and no longer moves a command that outlasts its Bash timeout to the background. A long command now finishes in the turn or is stopped at the Bash timeout: 2 minutes, unless the agent asks for a longer one. Codex, OpenCode and the verifier ignore the variable.docs/agents-and-sandboxes.mdx(Supported agents) describes the behavior. It also shows how a skill whose single commands need longer can raise Claude Code's default withBASH_DEFAULT_TIMEOUT_MSinharbor.runtime_env, keeping it below the agent timeout. CHANGELOG has one entry under Unreleased → Fixed.Why
A
claude-codetrial can answer and still never finish. In a headless--printrun, Claude Code waits for its background commands before it exits. It also moves a foreground command that outlasts its Bash timeout to the background on its own. So a command that never ends keeps Harbor'sclaude ... --print | teepipeline open after the final answer. One example is an agent runninggrep -r /to look for a skill that is not installed. The trial then runs until the agent timeout and is recorded as an unscored agent timeout. Coverage drops, and a retry hits the same hang.Reproduced against Claude Code 2.1.293 (one patch release after the pinned 2.1.292). The test used Harbor's launch pipeline and a scripted local Messages endpoint. The model ran
tail -f /dev/nullthrough Bash, then answered.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1run_in_backgroundclaudestill running at 45srun_in_backgroundis not in the Bash schema; the request is rejected and the pipeline exits right after the answerclaudestill running at 45sHarbor 0.24's
ClaudeCodeagent does not set this variable.Kept from public
Existing evaluator-managed task environment. The variable goes through the same mapping that already enforces
CLAUDE_CODE_DISABLE_POLICY_SKILLS=1. This one path covers:claude-codeand the SkillEvaluator wrappers, including the NVIDIA Build bridge agentsNo per-agent env builder and no
--agent-envforwarding was added. The test that judge settings are never forwarded as agent env still guards that path.Existing override protection. The managed mapping is merged last, so a native task's
[environment.env]cannot set the variable back to0. The runner already rejects anyCLAUDE_CODE_*name inharbor.runtime_envas operator-owned. The new tests pin both.Existing
harbor.runtime_env. It already accepts a literalBASH_DEFAULT_TIMEOUT_MS, so skills can raise Claude Code's per-command default today. This PR documents that instead of adding a dedicated config key.No Dockerfile change. The image-level
ENVreset stays limited to the skill-discovery policy, so cached task images are not invalidated.Tests
tests/test_harbor_claude_background_tasks.py(5 tests). All 5 fail without the adapter change and pass with it.[environment.env]that Harbor'sTaskConfigparses.harbor.runtime_envcannot set it: the runner rejects the name, and the managed value wins in the staged task."0"in[environment.env]is staged with"1"."1"even when the host sets0and Harbor's Claude Code agent passes its own per-command variables. Skipped on Windows.main:-n 8): 2039 passed, 5 skipped, 5 failed. None of the 5 failures is caused by this change:*sidecar_retains_*tests intest_harbor_secure_docker_environment.pydepend on host environment variables. They fail the same way on unmodifiedmain.ruff checkandruff format --checkon the changed Python files: clean.scripts/check_oss_boundary.py: passed.🤖 Generated with Claude Code