Skip to content

feat(sandbox): typed sandbox failures and one agent-OOM policy for sandboxed benchmarks - #5504

Closed
AdamRajfer wants to merge 21 commits into
yuhez/2135-judge-recoveryfrom
arajfer/sandbox-failures
Closed

AdamRajfer wants to merge 21 commits into
yuhez/2135-judge-recoveryfrom
arajfer/sandbox-failures

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a sandboxed episode ends abnormally, Gym's treatment depends on the benchmark and the agent that observed it. A memory kill of the agent's container is scored 0 by one benchmark, masked and retried as infrastructure by another, and reaches collection as a generic agent route failure in a third. The cause, phase and container are recovered from free text by four separate matchers.

What this PR does

  1. Typed sandbox failures. Builds on the sandbox failure boundary and SandboxFailureDetails from feat(failures): add typed boundary details #5505 and adds the container field. The provider's ended-sandbox report is read in one place (nemo_gym.sandbox.failure_details): the provider's reason code as reported (OOMKilled, Evicted, Error), the cause (oom, evicted, storage, unknown) and, when the report names it, which container ended (the agent's, an init container or a sidecar). The kind follows the typed reason: the agent's own memory kill is provider_oom_killed, and any other ending, including evictions and a helper container's memory kill, is provider_unavailable.
  2. Producers. The sandboxed coding agent, the harness agent and the Harbor agent observe a typed sandbox failure beside the failure they already report, so the selected failure, its kind and the reply are unchanged. The text matchers read the typed reason first and keep the text only as a fallback for records saved before this change.
  3. One agent-phase OOM policy. A rollout whose failure events hold a provider-reported OOMKilled of the agent's own sandbox at stage agent is a final zero: counted in the denominator and never retried. Kills during setup or verification, a helper container's memory kill and any other provider reason stay infrastructure retries.
  4. Recovery and health. Recovery and the acceptance gate treat that zero as the model's result. The run-and-babysit-eval skill and the rollout-health page describe it.
  5. Health and observation labels (no scoring or retry change). A rollout_tool_call_failed finding for tool outputs that report a harness tool failure, and a warning when the coding agent's sandbox has no network access and no local rg binary is configured, because its search tools then fail.

Behaviour notes

  • A reader that scans every event of a row, not only the selected one, now also sees the sandbox failure. An agent-timeout row that also holds a provider-ended sandbox event with a non-memory reason therefore counts as an infrastructure timeout.
  • The harness agent's kind follows the provider's typed reason. A report whose reason is Error but whose text says exited with code 137 is now provider_unavailable, not provider_oom_killed; both are retried.

Known limitations

  • The configured memory limit is not yet compared with the limit the sandbox ran under.
  • The harness agent reports the agent's own memory kill as a masked result, which recovery retries instead of scoring.
  • A memory kill whose report names no container is attributed to the agent.

Relation to #5127–#5129

#5127, #5128 and #5129 cover much of the same ground with a different design, and they are the base for this area:

Not in this PR (follow-ups)

  • Run health counts agent-OOM zeros, evictions and masked verifications per benchmark.
  • Benchmarks treat evictions and non-memory provider endings as infrastructure in their scoring (the typed kind above already classifies them; Terminal-Bench 4 still scores a storage eviction 0).
  • An incomplete verification (verifier timeout, missing or empty reward) in the terminal benchmark is masked as verifier_error instead of saved as an unmasked 0.
  • Timeouts, 5xx and connection errors in the middle of a rollout become failure events and are retried as infrastructure.
  • The verifier grades the final state after an agent timeout instead of failing on its first command.
  • The coding agent's search tool is staged from the image instead of being downloaded during the episode.
  • The rescoring and settlement path applies the new policy to completed runs from their saved failure records.

Validation

  • Required checks on this head: unit tests, server suite, lint and DCO pass.
  • Tests cover the agent-phase OOM policy, the typed reason and container parsing, the harness agent's kind from the typed reason, the Harbor and coding-agent producers, and the two health labels.
  • Applied alone on current main, this PR's own changes import cleanly and its own tests pass (447 unit tests, 177 agent tests); the only overlap with main is one import list.
  • Full unit suite of the stack that contains this head: the same failure set as main.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 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.

AdamRajfer and others added 2 commits November 3, 2026 17:59
An ended sandbox was recognized by several text matchers, each reading a
different part of the provider's message, and the failure events said
nothing typed about it.

nemo_gym.sandbox.failure_details reads OpenSandbox's ended-sandbox report
(and Gym's own notice after a backend loss) in one place. The failure
event carries SandboxFailureDetails as the schema defines them: the
sandbox and execution ids, the provider and the provider's reason code
as reported (OOMKilled, Evicted, Error), short enough that the whole
event stays inside one failure-report header; no exit status is
synthesized. The report also names the container that ended and whether
an eviction was for storage; EndedSandbox keeps those readings beside
the details for the caller that decides the kind. The kind follows the
reason: provider_oom_killed exactly for OOMKilled. The phase is the
event's stage.

The coding agent, the harness agent and the Harbor agent observe that
sandbox failure beside the failure they already report, so their
replies, kinds and retries do not change. The harness agent's OOM kind
now follows the typed reason; its text markers decide only where no
report of an ended sandbox exists.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ommand is a final zero

A provider-confirmed memory kill of the agent's sandbox while the agent's
command ran was retried as infrastructure on one benchmark and masked on
another. A retry resamples a model that exhausted the benchmark's memory
limit, so the same event moved scores differently from one benchmark to
the next; an upstream harness scores such a trial 0 and keeps it in the
denominator.

rollout_recovery.agent_phase_oom reads a rollout's failure events: a
sandbox failure of kind provider_oom_killed (the provider reported
OOMKilled) at stage agent. Collection marks such a failed rollout
terminal and counted as zero, both when the agent's request raised and
when it returned a failure-class result, so it is a final zero in the
denominator and is never retried. A kill during setup or verification,
any other provider reason (an eviction, an Error ending) and an exit
status without a provider report stay retryable infrastructure, as
before.

Known limitation: the event does not yet say which container of the
sandbox ended, so a helper container killed for memory during the
agent's command also counts; this tightens when the event names the
container. A masked result row (the harness agent) is not covered yet.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AdamRajfer
AdamRajfer force-pushed the arajfer/sandbox-failures branch from 7c5af09 to 649caa1 Compare November 3, 2026 17:01
AdamRajfer and others added 3 commits November 3, 2026 18:27
A memory kill of a sandbox's helper container (a sidecar or an init
container) is not the agent's own, yet the typed sandbox failure called
every provider-reported memory kill provider_oom_killed, so a helper
container's kill during the agent's command became a final zero.

The failure details now carry the container name as the provider
reported it. The event kind is provider_oom_killed only when the
provider reported a memory kill of the agent's own container, or named
no container (Gym's own notice after losing the exec backend); a
sidecar or init container's memory kill is provider_unavailable and is
retried like any other infrastructure failure. The harness agent's
failure kind follows the same reading.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A rollout whose agent's own sandbox was killed for memory during the
agent's command is made a terminal counted zero, but recovery did not
own such a row (its cause is a sandbox failure, not a model request), so
the run stayed incomplete, and the health gate classed every provider
kind as a server fault, so a few such kills could fail the 2%
evaluation-health limit.

Recovery now reads a counted terminal row whose failure events hold an
agent-stage memory kill as the model's final result. The gate counts
it under the derived class agent_sandbox_oom_killed, a model fault that
keeps its sandbox cause in the trial failure rates and ignores the HTTP
status of the failed reply. provider_oom_killed itself stays
evaluation-side: a setup or verification kill, and a row without the
final-zero markers, are unchanged.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The sandbox-killed-for-memory note now says what the stack does: an
agent-stage kill of the agent's own container is a final zero, kept in the
denominator, never retried and counted as a model fault by the health
gate, for the Harbor general and sandboxed opencode agents. A helper
container's kill, a setup or verification kill, other provider endings
and an exit status without a provider report stay retried
infrastructure. The fault class list names the new gate-derived kind.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@AdamRajfer
AdamRajfer changed the base branch from arajfer/stack-top to yuhez/2135-judge-recovery November 3, 2026 19:44
@AdamRajfer
AdamRajfer added this pull request to stack #5408 November 3, 2026 19:45
…dbox-failures

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test ec697ac

…dbox-failures

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 4674673

… modules

The agent-phase OOM policy tests imported NG_FAILURE_CLASS_KEY and
NG_TERMINAL_KEY through package facades. The facade test requires the
library's own tests to import each name from the module that defines it.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 37d763d

…dbox-failures

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 6437153

…into arajfer/sandbox-failures

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

# Conflicts:
#	.agents/skills/gym-eval/SKILL.md
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 5fa42e9

…dbox-failures

Main's #5536 moved the failure modules into their packages; this layer's imports, patch targets and moved test-module paths follow, and servers and agents import facade-served names from the facades. Import paths only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 0e1d033

AdamRajfer and others added 6 commits November 3, 2026 23:10
…ailures

A tool output that opens with the text a harness returns when a tool could not run at all (starting with "ripgrep execution failed") now produces one tool_call_failed finding per rollout, with the number of such outputs in its detail. It is a label only: rewards, verdict rules for other checks and retry decisions are unchanged.

OpenCode sandboxed agents without network access cannot download ripgrep, so every grep call fails. The agent now logs a warning at load when its sandbox has no network access (network_access, or enforce_agent_no_network on the resources server) and local_ripgrep_binary_path is not set.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…esource limit

rollout_missing_agent_turns still reports a rollout with no agent turns. When the record carries sandbox_resource_limit, its detail now also holds expected_absence = sandbox_resource_limit:<resource>, so a reader can tell the missing turns follow a provider-ended sandbox. The finding, the reward and retry decisions are unchanged.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ailure event

An OpenCode sandboxed agent run whose staging upload or agent exec raises TimeoutError or SandboxBackendUnreachableError, and whose error reports no provider-ended sandbox, now observes a sandbox failure event beside the failure it already reports: transport_timeout for a timeout and provider_unavailable for an unreachable backend, at stage seed for the uploads and agent for the exec, with the call named as the operation.

This only observes. The raised error, the route failure, the retry decision and the counts-as-zero marker are unchanged; a provider-ended sandbox keeps its existing typed event, and an error never yields two events.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ll_failed

The check emits one finding per rollout with a count, so it is a rollout-subject check and its id starts with rollout_. This drops the CheckSubject.TOOL_CALL member the previous commit added, so no public enum is added. Behavior is otherwise unchanged.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Five known gaps, each to be fixed later: the harness agent retries its own memory kill as a masked result; Terminal-Bench 4 counts a helper-container memory kill as the agent zero; a memory kill that names no container is attributed to the agent; a storage eviction is a model zero in Terminal-Bench 4 but an infrastructure retry in the OpenCode path; and Terminal-Bench 4 scores verifier timeouts and missing reward files as unmasked zeros while DeepSWE masks and re-verifies them. No behavior changes.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
After the core and utils module moves, the library's tests import each
name from its defining module and the agent's tests from the package's
public API, as the facade tests require.

Signed-off-by: Adam Rajfer <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the base branch's latest documentation, message and skill fixes. No conflicts; nothing changed in this branch's own code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test d9ce80f

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Brings in the base branch's latest head, which merges main through #5564 (the episode modules split into types, context and failure records) and later main changes. This layer's imports of moved names follow the new modules. Import paths only. SandboxFailureDetails moved to nemo_gym.core.failure_records; this branch's container field and its docstring move with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test ff66e96

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test f553e73

Brings in the base branch's merge of main, which now carries #5343 as one squashed commit. The tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 3b55e4e

This branch was previously deployed

1 inactive deployment
public — 3b55e4e2 Deployed Nov 4, 2026 by copy-pr-bot[bot] via release / finalize / notify #9982
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