Skip to content

fix(harness_agent): mask rollouts the sandbox provider reports as failed - #5354

Merged
cmunley1 merged 5 commits into
mainfrom
kbhardwaj/harness-agent-mask-sandbox-failures
Oct 31, 2026
Merged

cmunley1 merged 5 commits into
mainfrom
kbhardwaj/harness-agent-mask-sandbox-failures

Conversation

@kbhardwaj-nvidia

@kbhardwaj-nvidia kbhardwaj-nvidia commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What

harness_agent now masks rollouts whose sandbox the provider reports as failed, instead of failing /run with HTTP 500:

  • During the episode, an OpenSandbox SDK exception (e.g. SandboxApiException with SANDBOX::ENDED when the container was OOM-killed or evicted), Gym's SandboxCreateError or SandboxBackendUnreachableError, or a TimeoutError/ConnectionError (to the sandbox or to the resources server) returns a masked row: mask_sample=true, evaluation_completed=false, reward=0, failure_kind provider_oom_killed when the provider's message names an OOM kill (exited with code 137, OOMKilled, Sandbox was OOM-killed), else provider_unavailable. The sandbox is closed first.
  • Everything else still fails /run as before. Runner output never decides it, and a runner that exits on a signal or with 137 stays a runner failure, since the agent's own commands can cause either.

Why

No issue. Running SWE Atlas QA (OpenCode, 124 x 3, OpenSandbox) for a series of RL checkpoints, single dead sandboxes failed /run with HTTP 500, which aborted the collection or, with route_failures_to_sidecar, scored the rollout as a policy failure (zero) although the policy never finished.

Validation

  • pytest responses_api_agents/harness_agent/tests on this branch, after merging main: 56 passed. The classifier test covers SDK 410s (OOM and eviction), backend loss (502 and OOM), creation failures, timeouts, and runner failures that must not mask (a log quoting SANDBOX::ENDED, exits 1, 137 and -1). run() tests cover a masked SDK 410, a masked backend OOM, and a propagated agent crash; a responses() test covers a signal-killed runner staying a runner failure.
  • pre-commit run --files <changed files>: passed.

Rollout evidence

An earlier version of this change ran on the #4777 head for SWE Atlas QA evals of nine checkpoints (372 rollouts each); 2-5 rollouts per run ended in SandboxApiException: ... HTTP 410 SANDBOX::ENDED, were masked, and every collection completed. That version also masked runners killed by a signal well before their deadline; review showed the agent itself can send that signal, so this PR no longer does.

Compatibility

Rollouts that used to fail the run on a provider-reported sandbox failure now return masked rows; consumers should drop mask_sample rows (the Atlas resources server already masks its own verification failures, #5105).

Proposed labels: bug, area:agent.

🤖 Generated with Claude Code

A task sandbox that dies mid-episode (OpenSandbox SANDBOX::ENDED, e.g. its
container OOM-killed with exit 137), one that cannot be created, or a
transport failure to it used to fail /run with HTTP 500 and abort the whole
collection. Those rollouts measure the infrastructure, not the policy: they
now come back masked (mask_sample=true, evaluation_completed=false) with
failure_kind provider_oom_killed or provider_unavailable, and the sandbox is
closed. Other errors still fail the run.

A runner killed by a signal well before rollout_timeout (a pod evicted or
recycled under load) is reported as RunnerTerminatedError and masked the
same way; at the deadline it is still the agent running out of time.

Signed-off-by: Khushi Bhardwaj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@kbhardwaj-nvidia kbhardwaj-nvidia added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working labels Oct 30, 2026
kbhardwaj-nvidia and others added 2 commits October 30, 2026 09:47
Resolves the import conflicts with the config and core moves (#5189, #5203):
the failure kinds now come from nemo_gym.core and SandboxCreateError from
nemo_gym.sandbox, like the rest of the agent's imports.

Signed-off-by: Khushi Bhardwaj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…masks

Timeouts and dropped connections count wherever they happen during the
episode, including a call to the resources server, not only to the sandbox.

Signed-off-by: Khushi Bhardwaj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kbhardwaj-nvidia
kbhardwaj-nvidia marked this pull request as ready for review October 30, 2026 16:49
@kbhardwaj-nvidia kbhardwaj-nvidia added the needs-review PR is ready for code review and waiting on a reviewer label Oct 30, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 30, 2026 16:50

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD — 2 BLOCKERs, 2 RISKs, and 1 NOTE.

The new masking paths can discard agent-caused failures, while some confirmed runtime failures still escape masking. Findings below include targeted corrections and proposed regression checks.

Completed inspection of both changed files and their affected provider, runner, lifecycle, response, and aggregation contracts. Considered the rollout evidence supplied in the PR. This review was static; no tests were executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

kbhardwaj-nvidia and others added 2 commits October 30, 2026 11:39
A runner killed by a signal before its deadline, or a runner log quoting
SANDBOX::ENDED, does not show that the runtime failed: the agent's own
commands can send the signal or print the text. Neither masks a rollout any
more; RunnerTerminatedError and the text checks are gone. Gym's
SandboxBackendUnreachableError (OpenSandbox backend loss, including its
"Sandbox was OOM-killed" report) now does, alongside the SDK's exceptions,
SandboxCreateError, and timeouts or dropped connections.

Signed-off-by: Khushi Bhardwaj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kbhardwaj-nvidia kbhardwaj-nvidia changed the title fix(harness_agent): mask rollouts lost to the sandbox runtime fix(harness_agent): mask rollouts the sandbox provider reports as failed Oct 30, 2026
@cmunley1

Copy link
Copy Markdown
Contributor

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP — prior findings resolved; no eligible regressions found.

Verified all five findings from review 5715938828 against the current source:

  • The classifier no longer masks ordinary runner failures based on log text or exit 137. It now recognizes Gym’s typed backend-loss exception and its OOM message.
  • The runner-failure branch no longer promotes signals using elapsed time. Removing that exception path also eliminates the reported timing and diagnostic-classification failures.
  • The regression tests retain SDK OOM/eviction masking, assert typed backend-OOM masking, and distinguish ordinary runner failures.

Completed follow-up inspection of both changed files and directly affected provider, import, cleanup, and response contracts, compared with the previous reviewed head. No introduced regression exceeding the historical moderate-impact ceiling was established. This was a scoped follow-up, not a fresh whole-PR review. Static inspection only; no tests were executed.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@cmunley1
cmunley1 added this pull request to the merge queue Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41153737197

Merged via the queue into main with commit 402020a Oct 31, 2026
49 of 52 checks passed
@cmunley1
cmunley1 deleted the kbhardwaj/harness-agent-mask-sandbox-failures branch October 31, 2026 01:45

This branch was previously deployed

1 inactive deployment
public — 16658c86 Deployed Oct 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #8758
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants