Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

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

Narendran Raghavan1e147a858313
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85d68a2c..159c60e0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -221,6 +221,21 @@ All notable changes to SkillEvaluator are documented in this file.
output is redirected or the search runs inside `sh -c`. Host and bundled
scoring agree, while scoped searches and slash-valued patterns retain their
classification.
+
+- Tier 3 `claude-code` trials no longer hang until the agent timeout after the
+ agent has already answered. Claude Code moves a shell command that outlasts
+ its Bash timeout to the background, and a headless run waits for background
+ commands before it exits, so a command that never finishes (for example a
+ `grep -r /` search for a missing skill) held the trial open and the case was
+ recorded as an unscored agent timeout. Generated and native tasks now set
+ `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1` in the task environment for every
+ env mode, so each command finishes in its turn or is stopped at Claude Code's
+ Bash timeout (2 minutes unless the agent requests a longer one). Neither
+ `harbor.runtime_env` nor a native task's `[environment.env]` can turn
+ background tasks back on, and other agents ignore the variable. A skill whose
+ single commands need longer can raise Claude Code's default with
+ `BASH_DEFAULT_TIMEOUT_MS` in `harbor.runtime_env`.
+
- PII email scans recognize all RFC 2606 reserved domains, including their
subdomains, mixed-case forms, trailing dots, and prose ellipses. A local-part
boundary prevents quadratic rescanning of long excluded addresses. Ordinary
diff --git a/docs/agents-and-sandboxes.mdx b/docs/agents-and-sandboxes.mdx
index 86eaa310..ba59f2b8 100644
--- a/docs/agents-and-sandboxes.mdx
+++ b/docs/agents-and-sandboxes.mdx
@@ -30,6 +30,20 @@ The pinned CLI releases apply wherever Harbor installs the agent: Docker and
the remote environments. [Local mode](#local-mode) runs the CLI already on your
machine instead.
+Claude Code runs with background tasks turned off. Every staged task sets
+`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1` in its environment, in every env mode,
+so a shell command finishes in the agent's turn or is stopped at Claude Code's
+Bash timeout (2 minutes unless the agent requests a longer one) instead of
+moving to the background. A headless Claude Code run waits for its background
+commands before it exits, so a command that never finishes would otherwise hold
+a trial that has already answered until the agent timeout. Neither
+`harbor.runtime_env` nor a native task's `[environment.env]` can turn
+background tasks back on. If a skill needs a single command to run
+longer, raise Claude Code's default in `evals/config.yml` with
+`harbor.runtime_env: {BASH_DEFAULT_TIMEOUT_MS: "240000"}` (milliseconds), and
+keep it below the trial's agent timeout: 300 seconds times
+`harbor.timeout_multiplier` for generated tasks.
+
The `claude` alias is canonicalized to `claude-code` everywhere an agent
name can appear — `-a/--agents`, `--agent-model`, and `harbor.agents` in
`evals/config.yml` — so both spellings always name the same agent.
diff --git a/src/skillevaluator/tier3/harbor/adapter.py b/src/skillevaluator/tier3/harbor/adapter.py
index 9cb322d3..8fda02f8 100644
--- a/src/skillevaluator/tier3/harbor/adapter.py
+++ b/src/skillevaluator/tier3/harbor/adapter.py
@@ -3635,6 +3635,11 @@ _RUNTIME_POLICY_ENV_RESET = 'ENV CLAUDE_CODE_DISABLE_POLICY_SKILLS="1"'
_EVALUATOR_MANAGED_RUNTIME_ENV = {
**dict.fromkeys(_RUNTIME_LOADER_ENV_NAMES, ""),
"CLAUDE_CODE_DISABLE_POLICY_SKILLS": "1",
+ # A headless Claude Code run waits for its background commands, so one that
+ # never exits (for example ``grep -r /``) holds a trial that has already
+ # answered until the agent timeout. With background tasks off, a command
+ # ends in its turn or at the Bash tool timeout. Other agents ignore it.
+ "CLAUDE_CODE_DISABLE_BACKGROUND_TASKS": "1",
}
_CLEAR_SKILL_ROOT_FUNCTION = (
"clear_skill_root() { target=$1; "
diff --git a/tests/test_harbor_claude_background_tasks.py b/tests/test_harbor_claude_background_tasks.py
new file mode 100644
index 00000000..31428fe5
--- /dev/null
+++ b/tests/test_harbor_claude_background_tasks.py
@@ -0,0 +1,114 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Claude Code background tasks stay off in every staged Tier 3 task.
+
+A headless Claude Code run waits for its background commands, so a command
+that never exits held a trial that had already answered until the agent
+timeout, and the case was recorded as an unscored agent timeout.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+from pathlib import Path
+
+import pytest
+from harbor.models.task.config import TaskConfig
+from harbor.models.trial.paths import TrialPaths
+
+from skillevaluator.tier3.harbor.adapter import (
+ _write_task_toml,
+ generate_harbor_tasks,
+ stage_native_harbor_tasks,
+)
+from skillevaluator.tier3.harbor.local_environment import SkillEvaluatorLocalEnvironment
+from skillevaluator.tier3.harbor.runner import _resolve_runtime_env
+
+_SWITCH = "CLAUDE_CODE_DISABLE_BACKGROUND_TASKS"
+
+
+def _write_skill(tmp_path: Path) -> Path:
+ skill = tmp_path / "demo-skill"
+ (skill / "evals").mkdir(parents=True)
+ (skill / "SKILL.md").write_text("# Demo Skill\n", encoding="utf-8")
+ (skill / "evals" / "evals.json").write_text(
+ json.dumps([{"id": "case-001", "prompt": "Use the skill."}]),
+ encoding="utf-8",
+ )
+ return skill
+
+
+def _staged_environment_env(task: Path) -> dict[str, str]:
+ config = TaskConfig.model_validate_toml((task / "task.toml").read_text(encoding="utf-8"))
+ return dict(config.environment.env)
+
+
[email protected]("with_skill", [True, False])
+def test_generated_tasks_disable_claude_code_background_tasks(tmp_path: Path, with_skill: bool) -> None:
+ skill = _write_skill(tmp_path)
+
+ [task] = generate_harbor_tasks(skill, tmp_path / "tasks", with_skill=with_skill)
+
+ assert _staged_environment_env(task)[_SWITCH] == "1"
+
+
+def test_skill_runtime_env_cannot_reenable_background_tasks(tmp_path: Path) -> None:
+ resolved, errors = _resolve_runtime_env({_SWITCH: "0"}, env_mode="docker")
+
+ assert resolved == {}
+ assert errors == [f"harbor.runtime_env.{_SWITCH} controls the host process and is not allowed"]
+
+ _write_task_toml(
+ tmp_path,
+ {"id": "case-001", "expected_skill": "demo-skill"},
+ has_skill=True,
+ runtime_env={_SWITCH: "0"},
+ )
+
+ assert _staged_environment_env(tmp_path)[_SWITCH] == "1"
+
+
+def test_native_tasks_cannot_reenable_background_tasks(tmp_path: Path) -> None:
+ skill = _write_skill(tmp_path)
+ native_task = skill / "evals" / "harbor" / "case-001"
+ native_task.mkdir(parents=True)
+ (native_task / "instruction.md").write_text("Run the native case.\n", encoding="utf-8")
+ (native_task / "task.toml").write_text(
+ 'schema_version = "1.3"\n\n[task]\nname = "nvidia/case-001"\n\n'
+ '[metadata]\nentry_id = "case-001"\n\n'
+ f'[environment]\n\n[environment.env]\n{_SWITCH} = "0"\n',
+ encoding="utf-8",
+ )
+
+ [staged] = stage_native_harbor_tasks(skill, tmp_path / "native")
+
+ assert _staged_environment_env(staged)[_SWITCH] == "1"
+
+
[email protected](os.name == "nt", reason="local mode requires a POSIX host")
+def test_local_mode_agent_commands_keep_background_tasks_disabled(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
+) -> None:
+ monkeypatch.setenv(_SWITCH, "0")
+ _write_task_toml(tmp_path, {"id": "case-001", "expected_skill": "demo-skill"}, has_skill=True)
+ task_config = TaskConfig.model_validate_toml((tmp_path / "task.toml").read_text(encoding="utf-8"))
+ (tmp_path / "environment").mkdir()
+ (tmp_path / "runtime").mkdir()
+ environment = SkillEvaluatorLocalEnvironment(
+ environment_dir=tmp_path / "environment",
+ environment_name="background-tasks",
+ session_id="background-tasks",
+ trial_paths=TrialPaths(tmp_path / "trial"),
+ task_env_config=task_config.environment,
+ runtime_agent="claude-code",
+ runtime_root=str(tmp_path / "runtime"),
+ sandbox_mode="off",
+ )
+
+ # Harbor's Claude Code agent passes its own per-command variables; the
+ # staged task value still reaches the CLI over the host's setting.
+ command_env = environment._exec_env({"IS_SANDBOX": "1", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"})
+
+ assert command_env[_SWITCH] == "1"