Skip to content

fix(opencode_sandboxed_agent): keep the provider kind when a sandbox command's outcome is unknown - #5859

Merged
AdamRajfer merged 2 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/opencode-provider-outcome-kinds
Nov 9, 2026
Merged

AdamRajfer merged 2 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/opencode-provider-outcome-kinds

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

What

opencode_sandboxed_agent raised a harness agent_route_failed ("Sandbox command outcome cannot be classified") whenever sandbox.exec returned a result that does not say how the command ended: an error_type other than timeout, or the -1 signal-death sentinel. The failed /run row then had no provider evidence, so a sandbox fault looked like an unnamed harness failure.

It now reports a provider_command_outcome_unknown sandbox event (provider, sandbox id and the provider's reason as typed details) and lets the agent route failure only route it (stage="agent"), the same shape pi_sandboxed_agent uses for the same situation. The collector types the failed row by that cause.

Genuine harness contradictions (missing launch marker, exit 0 without a completion marker, missing export) keep agent_route_failed. A timeout still reaches the verifier, and provider_oom_killed handling is untouched.

What does not change

Retry and scoring. The attempt was already unscored and rerun under the attempt cap, never counted as a model result unless a run explicitly counts agent_run_error as zero; that is unchanged. The agent-stage outcome policy is not consulted by this agent for a raised failure, so no policy rule is added (the default agent-stage action for the kind is fail and is only consulted by agents that can count a failure as zero; the environment-server agent policy already maps the kind to retry).

Which values reach the branch

  • Providers that return a runtime failure without a process exit: sandbox (docker, apptainer, enroot, openshell, daytona), pty, and OpenSandbox's user_switch_unavailable, all with exit code 125.
  • OpenSandbox reports a signal-killed process as exit code -1 with no error type; the OpenSandbox provider already raises typed provider_command_outcome_unknown / provider_status_unavailable events for missing or contradictory command status, and those propagate unchanged.

Tests

test_unconfirmed_exec_result_is_a_typed_provider_failure_and_does_not_grade_a_partial_workspace covers each of those values: the cause kind and details, the failure reason, the collector's row kind, the evaluation-side attribution, that the agent-stage policy does not count it as zero, and that the verifier is never called. It fails on main. responses_api_agents/opencode_sandboxed_agent, opencode_agent, pi_sandboxed_agent, tests/unit_tests/agents and tests/unit_tests/core pass; ruff check and ruff format are clean.

…command's outcome is unknown

When sandbox.exec returns a result that does not say how the command ended (an
error type, or the -1 signal-death sentinel), the agent reported it as a bare
harness agent_route_failed. The row then carried no provider evidence, so a
sandbox fault read as an unnamed harness failure.

Report it as a provider_command_outcome_unknown sandbox event, with the provider,
sandbox id and the provider's reason as typed details, and let the agent route
failure only route it (stage agent), as pi_sandboxed_agent already does. The
collector types the failed /run row by that cause. Retry and scoring are
unchanged: the attempt is still ungraded and rerun under the attempt cap, never
counted as a model result. Genuine harness contradictions (missing launch
marker, exit 0 without a completion marker) keep agent_route_failed.

Signed-off-by: Adam Rajfer <[email protected]>

@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 WITH CARE — the new test introduces an import-check failure, and required rollout evidence is missing.

RISK — Record a representative model-backed smoke rollout. The supplied validation lists unit tests and Ruff checks, but no real rollout evidence or justified N/A. This changes the observable failure contract in the agent execution branch, so the repository’s smoke-rollout requirement applies. Unit tests alone leave the running harness-to-collector integration unvalidated.

Could you run a representative task with a model at this head and add the config, provider, model, task, artifact location, and inspected agent/verifier results to the PR description? The normal rollout should reach verification and retain its native reward. A controlled unknown-outcome check should retain provider_command_outcome_unknown in the collected failure, produce no model score, and preserve the existing bounded rerun behavior. These are proposed acceptance checks, not executed results; they don't require new retry or scoring rules.

Preserve the neighboring cases: the timeout regression must retain its nonempty partial output and captured export, and the confirmed-OOM regression must retain the verifier’s reward without forcing zero.

I inspected both changed files and traced provider evidence, failure routing, collection, recovery, and verification preservation. I found no additional production-code defect. This was static review; I couldn’t execute tests or model rollouts with the available tools.

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

choose_stage_outcome,
failure_report_for,
)
from nemo_gym.core.failure_transport import FailureHeader

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.

RISK — Import FailureHeader through the public core API. This new import adds a failing entry to the repository-wide import guard. The guard scans server tests as code outside the library and rejects direct submodule imports of exported names. FailureHeader is already exported by the core facade, so this fails independently of whether the agent’s own suite passes. This conclusion comes from source inspection, not an executed test.

Could you add the name to the existing public import group and remove this line? The small patch at this location is:

     from nemo_gym.core import (
         FailureClass,
+        FailureHeader,
         NgFailureEvent,
         OutcomeAction,
         StageOutcomePolicyConfig,
         choose_stage_outcome,
         failure_report_for,
     )
-    from nemo_gym.core.failure_transport import FailureHeader

The facade returns the same class, so the failure contract should remain unchanged. Verify the patch by running the linked import guard and the five-case regression: the guard should report no entry for this import, and every case should still retain the typed provider details, encode a header that resolves to provider_command_outcome_unknown, and avoid downloads and verifier calls.

wprazuch
wprazuch previously approved these changes Nov 9, 2026
@AdamRajfer
AdamRajfer enabled auto-merge November 9, 2026 16:37
@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Merged via the queue into NVIDIA-NeMo:main with commit 007c088 Nov 9, 2026
68 checks passed
@AdamRajfer
AdamRajfer deleted the fix/opencode-provider-outcome-kinds branch November 9, 2026 17:26
svcnemo-autobot pushed a commit to svcnemo-autobot/Gym that referenced this pull request Nov 10, 2026
…VIDIA-NeMo#5925)

* fix(opensandbox): time out background commands at Gym's own deadline

execd reports the kill at a command's timeout only as a signal death (exit -1,
"signal: killed"), and since NVIDIA-NeMo#5127 the provider no longer infers a timeout from
that. With operations.background_exec a command that runs out its time therefore
never comes back as a timeout. A harness that treats an unexplained -1 as an
unknown outcome (opencode_sandboxed_agent since NVIDIA-NeMo#5859) reruns it as an
environment fault instead of verifying it.

Background exec now enforces timeout_s itself, as the session path already does:
it records provider_command_timeout, interrupts a command still running at the
deadline and returns 124 with error_type="timeout". execd's timer moves
command_timeout_headroom_s / 2 later and only stops a command whose interrupt was
refused; a refused interrupt keeps the reported exit.

Signed-off-by: Adam Rajfer <[email protected]>

* fix(opensandbox): keep status polling cadence after Gym's command deadline

When status reads failed after the command deadline, the past deadline stayed in
the sleep limits and zeroed the polling and backoff delay until the status
recovery window ran out. Only a future deadline now shortens the sleep. Adds a
regression test for a status outage that spans the deadline.

Signed-off-by: Adam Rajfer <[email protected]>

---------

Signed-off-by: Adam Rajfer <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 542e04d7 Deployed Nov 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #11058
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.

3 participants