Skip to content

fix(tier3): disable Claude Code background tasks in eval trials - #268

Merged
rng1995 merged 1 commit into
mainfrom
naren/port-claude-disable-background-tasks
Nov 2, 2026
Merged

rng1995 merged 1 commit into
mainfrom
naren/port-claude-disable-background-tasks

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Background tasks off for every trial. CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 is added to _EVALUATOR_MANAGED_RUNTIME_ENV in tier3/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.
  • Effect on Claude Code. Claude Code drops run_in_background from 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 and changelog. 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 with BASH_DEFAULT_TIMEOUT_MS in harbor.runtime_env, keeping it below the agent timeout. CHANGELOG has one entry under Unreleased → Fixed.

Why

A claude-code trial can answer and still never finish. In a headless --print run, 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's claude ... --print | tee pipeline open after the final answer. One example is an agent running grep -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/null through Bash, then answered.

Scenario Without the variable With CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1
Agent asks for run_in_background Final answer at about 9s; claude still running at 45s run_in_background is not in the Bash schema; the request is rejected and the pipeline exits right after the answer
Foreground command outlasts a 6s Bash timeout "moved to the background"; final answer at about 11s; claude still running at 45s "Exit code 143, Command timed out after 6s"; the pipeline exits right after the answer

Harbor 0.24's ClaudeCode agent 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:

    • every env mode: docker, kata, gke, local, the Harbor-native remote modes and custom execution backends
    • stock claude-code and the SkillEvaluator wrappers, including the NVIDIA Build bridge agents
    • generated and native tasks

    No per-agent env builder and no --agent-env forwarding 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 to 0. The runner already rejects any CLAUDE_CODE_* name in harbor.runtime_env as operator-owned. The new tests pin both.

  • Existing harbor.runtime_env. It already accepts a literal BASH_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 ENV reset stays limited to the skill-discovery policy, so cached task images are not invalidated.

Tests

  • New tests/test_harbor_claude_background_tasks.py (5 tests). All 5 fail without the adapter change and pass with it.
    • Generated tasks, both the with-skill and the baseline arm, carry the variable in the [environment.env] that Harbor's TaskConfig parses.
    • harbor.runtime_env cannot set it: the runner rejects the name, and the managed value wins in the staged task.
    • A native task that sets it to "0" in [environment.env] is staged with "1".
    • In local mode, the agent command environment keeps "1" even when the host sets 0 and Harbor's Claude Code agent passes its own per-command variables. Skipped on Windows.
  • Local runs, after rebasing onto current main:
    • Targeted suite for the adapter, runner, local and secure Docker environments, GKE, custom execution backends, runtime skill isolation, character facts and Tier 3 progress (16 files, -n 8): 2039 passed, 5 skipped, 5 failed. None of the 5 failures is caused by this change:
      • The 2 *sidecar_retains_* tests in test_harbor_secure_docker_environment.py depend on host environment variables. They fail the same way on unmodified main.
      • The redaction-overlap test and the 2 bounded-process timeout tests failed under parallel load on a heavily loaded host. Run serially, the redaction test and the descendant-reaping test pass. The diagnostic-tail test uses a 0.1 s timeout for a child Python process and still timed out before the child wrote its first line. It does not touch the task environment this change edits.
    • All 5 new tests pass on the rebased branch.
    • ruff check and ruff format --check on the changed Python files: clean.
    • scripts/check_oss_boundary.py: passed.
  • Manual check: the Claude Code 2.1.293 reproduction in the table above.

🤖 Generated with Claude Code

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 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 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
chrisknvidia force-pushed the naren/port-claude-disable-background-tasks branch from b6ff5a6 to e44d872 Compare October 30, 2026 22:25
@rng1995
rng1995 merged commit 1e147a8 into main Nov 2, 2026
20 checks passed
@rng1995
rng1995 deleted the naren/port-claude-disable-background-tasks branch November 2, 2026 05:53
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.

1 participant