Skip to content

fix(tier3): retry transient Claude Code and Codex install failures - #277

Merged
rng1995 merged 9 commits into
mainfrom
naren/port-agent-install-retries
Nov 4, 2026
Merged

rng1995 merged 9 commits into
mainfrom
naren/port-agent-install-retries

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

SkillEvaluator's container wrappers for Claude Code and Codex now retry a failed agent CLI install instead of failing the trial on the first attempt.

  • SkillEvaluatorCodex.install() and SkillEvaluatorClaudeCode.install() in tier3/harbor/installed_agents.py wrap Harbor's own install() in a bounded retry: up to 3 attempts, waiting 2 s and then 4 s, with a warning log line per retry.
  • Only a Harbor command that exited non-zero (NonZeroAgentExitCodeError, which includes Harbor's NetworkConnectionError) is retried. That covers the vendor installer (Claude's bootstrap.sh, NVM, npm install -g) and the distribution package install for Node/npm. The platform probe's RuntimeError, transport errors such as TimeoutError, and cancellation still propagate on the first occurrence.
  • Every wrapper built on these classes inherits the retry: Docker and Kata Codex and Claude Code, the container Claude Code wrapper (also used on GKE), the OpenAI-compatible gateway Codex wrapper, and the NVIDIA Build bridge wrappers. Local mode's agents override install() to check the host CLI, so they are unchanged and still fail fast when the CLI is missing.
  • Docs: docs/agents-and-sandboxes.mdx (Agents) describes the retries and their bounds.
  • CHANGELOG: new entry under Unreleased, ### Fixed.

Why

Harbor runs each agent installer once. A dropped download, a DNS hiccup, a package mirror error or an npm registry timeout during setup fails the whole trial before the agent starts, and SkillEvaluator does not configure Harbor's trial-level retries. On a multi-agent or multi-case run, one transient network error during setup can turn a trial into an execution error and leave an agent without a score.

Retrying is safe: Harbor's install() first checks whether the requested CLI version is already present, so a retry skips a CLI that an earlier attempt installed. All attempts run inside Harbor's agent setup timeout, so an install that keeps failing still fails the trial, with the same exception Harbor raised before.

Kept from public

  • Harbor 0.24's stock installers are reused unchanged. The retry wraps install() instead of rewriting or patching installer shell commands, so it does not pin installer URLs and it picks up future Harbor installer changes.
  • The existing Node/npm and CA-bundle dependency selection (_installer_dependencies) and its tests are unchanged, including the fail-fast on an unrecognized platform probe and the propagation of probe transport errors. The new tests confirm that neither is retried.
  • Harbor's installed-version check, and local mode's installed-CLI version check, are unchanged.

Tests

  • New tests/tier3/test_installed_agent_install_retry.py (16 tests) drives the real Harbor install flow against a fake environment:
    • test_transient_installer_failure_is_retried: a curl: (6) Could not resolve host failure on the first installer run is retried once and the install completes, for the Codex, Claude Code, gateway Codex, NVIDIA Build and container Claude Code wrappers.
    • test_persistent_installer_failure_stops_after_bounded_attempts: after 3 failed attempts the original NetworkConnectionError propagates, with backoff delays of 2 s and 4 s.
    • test_transient_system_package_failure_is_retried: a failed distribution Node/npm install on the npm installer branch is retried.
    • test_platform_and_transport_errors_are_not_retried: an unrecognized platform probe and a probe TimeoutError fail on the first attempt, with no sleep and no installer run.
    • test_local_agents_do_not_retry_a_missing_host_cli: local mode still fails once when the host CLI is missing.
    • The 10 retry tests fail without the fix. The 6 negative tests pass with and without it.
  • pytest tests/tier3/test_installed_agent_install_retry.py tests/tier3/test_installed_agent_bootstrap.py tests/tier3/test_harbor_local_agents.py tests/tier3/test_gateway_codex.py tests/test_harbor_gke_mode.py: 581 passed.
  • pytest -n 8 tests/tier3 tests/test_harbor_*.py tests/test_oss_packaging.py tests/test_tier3_public_runtime.py tests/test_ci_change_classifier.py, rebased on current main: 9658 passed, 14 skipped, 15 failed. All 15 fail the same way on unmodified main and do not touch the agent install path. Two test_sidecar_retains_* tests in test_harbor_secure_docker_environment.py depend on host environment variables. Thirteen test_generated_custom_only_script_* tests in tests/tier3/test_judge_failure_artifacts.py run the generated verifier with the host's python3, which is Python 3.9 on the test machine.
  • tests/test_oss_packaging.py, tests/test_tier3_public_runtime.py, tests/test_ci_change_classifier.py: 429 passed.
  • ruff check, ruff format --check and scripts/check_oss_boundary.py: passed.
  • Not run: a live Docker evaluation with real network faults.

🤖 Generated with Claude Code

Harbor runs each agent installer once. A dropped download, DNS hiccup,
package mirror error or npm registry timeout during setup failed the
whole trial before the agent started, and SkillEvaluator does not enable
Harbor's trial-level retries, so one transient network error could leave
an agent without a score.

SkillEvaluatorCodex and SkillEvaluatorClaudeCode now wrap Harbor's own
install() in a bounded retry: up to three attempts, 2 s and then 4 s
apart, within Harbor's agent setup timeout. Only a Harbor command that
exited non-zero (NonZeroAgentExitCodeError, including
NetworkConnectionError) is retried; the platform probe's RuntimeError,
transport errors and cancellation still propagate on the first
occurrence. Harbor's install() skips a CLI an earlier attempt already
installed, so rerunning it is safe. The gateway Codex, NVIDIA Build and
container Claude Code wrappers inherit the retry; local mode, which
checks the host CLI instead of installing, is unchanged.

Harbor's stock installers are reused as is, rather than patching their
shell commands, so future Harbor installer changes still apply.

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.

Reviewed with Claude Code. The retry wrapper is correct: it retries only Harbor's NonZeroAgentExitCodeError, lets probe, transport and cancellation errors through, and shares Harbor's setup timeout. Local agents are unaffected. The 16 new tests and ruff pass locally. One P3 below.

Comment thread CHANGELOG.md Resolved
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Conflicted files: docs/agents-and-sandboxes.mdx

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry wrapper is bounded (3 attempts, 2 s then 4 s), only catches the non-zero-exit error, and re-runs Harbor's own install(), whose version check skips a CLI that is already there, so a retry should not redo finished work. Probe, transport and cancellation errors still pass straight through, and the local agents are untouched. Two non-blocking points: the retry ignores how long the failed attempt took, and the warning drops the failure text.

rng1995 and others added 6 commits November 3, 2026 04:14
No conflicts.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retried install shares Harbor's agent setup timeout, so a slow failure
retried until the trial ended with a setup timeout instead of the install
error. An attempt that took over a third of the agent's setup timeout, or
that would leave no room for another attempt as long, is now raised without
retrying.

The retry warning now ends with the redacted, single-line tail of Harbor's
error, which holds the failed command's stderr, so each attempt's cause is
visible at the default log level.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re detail

Skip the retry when the failed attempt already used a third of Harbor's
agent setup timeout, so the original error is not replaced by
AgentSetupTimeoutError. Include the tail of the failure message in the
retry warning.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
…nstall-retries

Conflicts in installed_agents.py and test_installed_agent_install_retry.py; kept the redacted retry detail and the setup-budget guard, whose tests cover the slow-attempt and warning cases.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the CHANGELOG.md conflict: keep main's new Unreleased entry and
put this PR's entry after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 enabled auto-merge (squash) November 4, 2026 18:58
@rng1995
rng1995 merged commit a52c82b into main Nov 4, 2026
21 of 22 checks passed
@rng1995
rng1995 deleted the naren/port-agent-install-retries branch November 4, 2026 19:35
rng1995 added a commit that referenced this pull request Nov 5, 2026
Resolve the CHANGELOG.md conflict: keep main's install-retry entry (#277)
and add this PR's stop-on-pass entry after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants