Repository navigation
fix(opencode): keep sandbox-reported errors over export errors - #6175
Conversation
When the sandbox kills an OpenCode run at its deadline, the exec result carries error_type="timeout", but the session export often holds an error on its last assistant message as well (the request the kill aborted). The agent recorded the export error whenever it had no run error of its own, so opencode_error_type came out as the export's error name and rules that match opencode_error_type == "timeout" missed those rollouts. A sandbox-reported error now outranks the export's terminal error. Without one, the export error still classifies the failure as before. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
|
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. |
Only the exec timeout reaches this branch: an out-of-memory kill raises at exec and every other sandbox error type is rejected before the export is read. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM. No concerns found.
I checked the error-precedence change and regression cases, including sandbox error guards and downstream verification and timeout-health handling. Sandbox timeouts keep priority, while failures without a sandbox error still use the export error.
I did not execute tests or reproduce the reported smoke rollouts in this read-only review.
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.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43952114923 |
… by NVIDIA-NeMo#6175 Signed-off-by: bg51717 <[email protected]>
What changed
The OpenCode sandboxed agent now keeps the sandbox's error type when the session export also holds an error.
When the sandbox stops an OpenCode run at its deadline, the exec result reports
error_type="timeout". The session export can hold an error on its last assistant message as well: the model request that the stop aborted. The agent copied that export error intoopencode_error_typewhenever it had no run error of its own, so the result named the export error instead oftimeout. Rules that matchopencode_error_type == "timeout", such as masking rollouts that ran out of time, then missed those rollouts, and so did Gym's own rollout health timeout report, which reads the sameopencode_error_typesignal.A sandbox-reported error now outranks the export's terminal error. In practice that error is the exec timeout: an out-of-memory kill raises at exec, and the agent rejects every other sandbox error type before it reads the export. When the sandbox reports no error type, the export error still classifies the failure, as before.
Sandbox provider
The original fix also changed the OpenSandbox provider to report a server-side command timeout as a timeout. This PR leaves the provider alone:
error_type="timeout", and it moves the server's own timer past that deadline as a backstop.Issue
No issue is linked. This restores behavior that NT4 training recipes rely on to mask rollouts that hit the agent deadline.
Validation
The new agent tests run a full OpenCode request in which the last assistant message in the session export carries an error. One case has the sandbox report a timeout and checks that the result's error type is
timeout. The other case has the sandbox report a plain failure with no error type and checks that the export's error name is still used. The timeout case fails without this change.Commands run:
PYTHONPATH=$PWD .venv/bin/python -m pytest responses_api_agents/opencode_sandboxed_agent/tests -n 16 pre-commit run --files responses_api_agents/opencode_sandboxed_agent/app.py responses_api_agents/opencode_sandboxed_agent/tests/test_app.pyRollout evidence
The smoke rollout ran from this branch at 355ff7e. It covers the timeout path end to end, but not the precedence branch itself; the agent tests cover that branch.
Setup:
background_exec: true, the path where Gym interrupts a command at its own deadline. Each sandbox used thepython:3.12image, and the pinned OpenCode version was installed at run time.openai/openai/eccn-gpt-6-lunaon the NVIDIA inference API. The remote sandboxes cannot reach the workstation, so OpenCode called the inference API directly through anopencode_config.provideroverride, not through Gym's model server.mcqaresources server, withsandbox_timeout: 240andexecution_failure_reward_zero: true.What the rollouts showed:
sleep 400 && caton it. In each one, the model made both bash calls and Gym interrupted the run at 240 seconds. Each rollout reportedopencode_exit_code124,opencode_error_type == "timeout"andopencode_failedtrue. The export was found, and the reward was 0.What the smoke did not reproduce: none of the timed-out exports had an error on its last assistant message. In every timed-out run, the deadline landed while a bash tool call was still running, and the interrupted process wrote nothing more to the session. Three more runs tried to place the deadline inside a long model response, but each response finished before the deadline. So no rollout reached the case where the export error and the sandbox timeout disagree. The agent tests above cover that case and fail without this change.
Compatibility
opencode_error_typechanges only for runs where the sandbox reported an error type and the export also held an error. Those runs now reporttimeoutinstead of the export's error name.