Repository navigation
feat: images in tool replies, a lent-sandbox helper and OpenCode session limits for multi-harness training - #5719
Conversation
|
/ok to test f22f699 |
|
/ok to test dda0bb5 |
This branch carried copies of the #5719 commits, so GitHub saw the opencode_agent README change twice and marked the PR as conflicting with its base, and no checks ran. Merging the base makes those commits ancestors. The README keeps this branch's text, which already has both the prompt-image paragraph and the max_output_tokens rule. Tests on the merged tree: opencode_agent and simple_agent 984 passed, agentic_mme 119 passed, agentic_mme_agent 85 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test af3c63b |
|
/ok to test 1132d70 |
|
/ok to test 5e12790 |
…, and drop agentic_if's copy of the default The opencode_agent config's comment now says what false costs: one turn per captured call, so evidence checks report every call as unmatched, and compaction summaries count as steps. agentic_if set the same value as the new default, so its line goes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…imit, as OpenCode does reached_step_limit() took the last user message as the prompt and counted the assistant messages after it. An automatic compaction adds user messages (the compaction marker, then a synthetic "Continue" text or a replay of the prompt), so the count restarted after a compaction, and a prompt that reached the limit was not marked. OpenCode 1.17.11's session loop (session/prompt.ts) counts passes: each build call, each compaction summary call, and a pass that only starts a compaction after a finished call overflowed (session/compaction.ts saves its marker without an overflow field). The counter is not reset by compaction. The check now skips the user messages that compaction adds when it finds the prompt, and counts those passes. Tests: five exports in OpenCode's message shapes, the overflow-pass and in-call compaction paths, a compaction with no continuing message, and a new prompt after a compacted one. Four fail on the old count. The README says how the limit is counted and when token capture allows it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…livery, and keep a failed seed's stop for retry Two cleanup gaps in LentSandboxes.lend(): - A seed cancelled while the new sandbox received its files left the sandbox running. AsyncSandbox.start() stops the sandbox when an upload fails, but that stop is not shielded, so it is cancelled with the request. lend() now runs start() inside its own failure path, whose shielded, bounded _stop() finishes the stop; after a stop that did finish, _stop() does nothing. - When a failed seed's stop failed or timed out, the sandbox was dropped, so no close or shutdown could stop it. It is now kept apart from the lent sandboxes: get() never returns it, release() and release_all() retry its stop, and the session's next lend stops it before it starts another sandbox (a failed stop there fails the lend). Tests: a seed cancelled during upload_file() with the real AsyncSandbox.start() and a provider close that crosses an AnyIO checkpoint; a failed seed whose first stop fails or hangs, stopped later by release() or release_all(); a repeated seed that stops the earlier sandbox first, and one that fails while that stop still fails. The seven new tests fail without the fix. test_sandbox_lending.py and tests/unit_tests/sandbox: 2028 passed, 8 skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…nd when token capture allows the step limit The harness guide's OpenCode row now matches the README: a session's opencode_config also accepts attachment (from #4922), and agent.build.steps works with token capture once the harness notes know OpenCode's step-limit message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 0447cf5 |
|
Thanks. Done, and one step further now that #4922 has merged: #5719 is rebased onto main (0447cf5) and shows only its own 22 commits.
|
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
One prior RISK remains: OpenCode accepts a response token budget but enforces only a per-call limit.
I verified three earlier findings are fixed in the current source:
- Both sandbox cleanup gaps are addressed: failed seeds now use shielded cleanup and retain allocations for retry. The regression tests cover cancelled uploads, failed or timed-out stops, and repeated seeds.
- Step-limit accounting no longer resets at compaction bookkeeping. The original counterexample now reaches the limit; tests also retain genuine-prompt reset behavior.
This was a static follow-up of the prior findings and identifiable corrections, not a fresh whole-PR review. I didn't run tests. The previously reviewed tree isn't mounted, so I couldn't independently compare the inter-review source delta or establish additional introduced regressions.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
…h model call, not the session's sum Gym agents read a request's max_output_tokens as the limit for each model call (simple_agent copies it into every call), and NeMo RL sets it on every row as its generation limit. The README and the code comment now say so, and that nothing limits the sum over a session's calls, as in simple_agent. No behavior changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 90534f7 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
One prior RISK remains: OpenCode accepts a response token budget but enforces only a per-call limit. The revised documentation describes that behavior; it doesn't resolve the earlier counterexample.
I confirmed that the previously acknowledged fixes remain in the current source:
- Both failed-seed cleanup gaps remain addressed by shielded cleanup and retained allocations for retry, with regression cases for cancelled uploads and failed stops.
- Step-limit accounting still preserves the prompt boundary across compaction. The regression cases retain compaction accounting and genuine-prompt reset behavior.
This was a static follow-up of the latest bot review, the documentation/comment changes since its mounted baseline, and their directly affected contracts—not a fresh whole-PR review. I didn't execute tests or independently verify the reported rollout results.
Review generated by codex. This was a findings-only 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/42761551132 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42763299259 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42768126306 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42771357435 |
What does this PR do?
Core pieces that let one environment run with several agent harnesses (
simple_agent, OpenCode, or the environment's own agent) through agent sessions, for eval and RL training. They came from moving Agentic-MME onto the Environment Server (#5720, stacked on this PR).nemo_gym.core.tool_output_images). A resources-server tool can return images undertool_output_images. The MCP layer sends them as MCP image content, andsimple_agentshows them to the model in a user message after the tool outputs. A result with images carries nostructuredContentunless the tool declares an output schema, because OpenCode replaces the content withstructuredContentand would drop the images. Each image is checked as prompt images are (MediaFile): valid base64 of a PNG, JPEG, GIF or WebP image.LentSandboxes(nemo_gym.server_runtime.sandbox_lending). A helper for a resources server that lends a per-episode sandbox to the harness: start it at seed (with optional files), describe it asSandboxAccess, stop it at close and at shutdown. A seed cancelled during file delivery still stops its sandbox, and a failed seed whose stop fails is kept so that close or shutdown can stop it.network_accessgives the lent sandbox the same egress rules an agent-owned sandbox gets:"model_only"denies all but the model server, and"model_and_tools"also allows the servers intool_servers, such as the resources server that serves the harness its tools over MCP.restricted_network_policymoves tonemo_gym.utils.network_policy;nemo_gym.agentsstill exports it.opencode_agent).opencode_configalso acceptscompaction.autoandagent.build.steps. Training needs compaction off, and a fair comparison between harnesses needs a step budget.harness_step_limit_reached: "true"in its metadata. The limit is counted as OpenCode counts it, compaction passes included. OpenCode's step-limit note asks for a final answer but still offers the tools. The environment decides whether an answer at the limit is scored (Agentic-MME's setting is in feat(agentic_mme): run Agentic-MME with simple_agent and OpenCode through agent sessions #5720).agent.build.stepsneeds the capture fix in fix(token_capture): keep capture chains through OpenCode's step-limit note and tool-name repair #5833. Without it, the seed refuses the setting (422). The check imports fix(token_capture): keep capture chains through OpenCode's step-limit note and tool-name repair #5833's harness notes, so either merge order works; it goes away once fix(token_capture): keep capture chains through OpenCode's step-limit note and tool-name repair #5833 is on main.max_output_tokensat or above the configured limit is accepted, so NeMo-RL rows no longer fail with 422.return_session_trajectorydefaults totrue, so the harness evidence checks can match each model call to its OpenCode step.Stack. #4917 and #4922 are merged; this PR is based on main. #5833 is independent. #5716 changes the same OpenCode settings with a different interface; only one of the two should land.
Compatibility
opencode_agentconfigs behave as before, except one default: close returns OpenCode's own turns (return_session_trajectory: falserestores the old behavior; training data does not change).input_imageparts of the tool output;vllm_modelneedsinline_tool_output_images: trueto accept them.Validation
simple_agent),LentSandboxes(including the model-only network), and the OpenCode session settings and defaults. On feat(opencode): attach prompt images in agent sessions #4922's head 49324d1 (the same tree as main after feat(opencode): attach prompt images in agent sessions #4922 merged), theopencode_agent,simple_agent, server runtime, sandbox, core and session contract tests pass (4,850 passed, 31 skipped), and pre-commit passes on the changed files.simple_agentwith the server's image tools 36.1% (the environment's own agent 34.9%), OpenCode with the same tools over MCP 36.5%.model_and_toolswas added (before the latest feat(opencode): attach prompt images in agent sessions #4922 rebase): both OpenCode configurations completed 10/10 with none masked, in line with the earlier rates. From inside the sandbox,model_and_toolsreached the resources server's MCP route, and neither setting reached the internet.Checklist
opencode_agentREADME, the harness guide, the MCP Resources Server page).pre-commit run --all-files).git commit -s).🤖 Generated with Claude Code