Repository navigation
fix(agents): stage activation files inside the close fence - #5862
Conversation
|
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. |
1733e8a to
da544a9
Compare
bce4aa2 to
2f4d2f1
Compare
OpenCode sessions uploaded the required-MCP plugin, the grant list and the empty grant status before the session's execute. Closing a session during those uploads could release the sandbox while they were still running. They now upload in stage_activation, next to prompt.txt, so close stops them before the sandbox is released. A continuation activation's deadline still bounds them, as before. A test checks that close cancels a stalled grant upload before the sandbox is released. Signed-off-by: Ananth Subramaniam <[email protected]>
2f4d2f1 to
5531cc3
Compare
The close test stalled only mcp-grants.json, so moving the plugin or the status upload back outside staging still passed. It now stalls each of the three files, in single-activation and continuation sessions, and runs the activation as a task rather than on a thread. A new test checks that a session without MCP grants stages none of the files. The stage_activation docstring said the activation deadline bounds staging. Single-activation sessions have no deadline; only continuation activations do. Signed-off-by: Ananth Subramaniam <[email protected]>
Pi and Codex uploaded their activation files before SandboxSession.execute, and their close releases the sandbox before it cancels the activation. A close during those uploads could release the sandbox while one was still writing. For Pi these are models.json, settings.json, its extensions, gym_mcp.mjs and mcp-servers.json; for Codex, config.toml. The MCP files carry the episode's tool session token. Both adapters now pass these files to stage_activation, which uploads them inside execute, so close cancels the uploads first. Codex keeps config.toml out of input.json, which holds the whole payload. Signed-off-by: Ananth Subramaniam <[email protected]>
The Pi close test stalled only mcp-servers.json, so moving models.json, settings.json, gym_mcp.mjs or an extension back before execute passed. It now stalls each staged file. The Pi and Codex tests expect the activation to end cancelled and bound the close, as the OpenCode test does. Remove Pi's unused upload_json, and say in the SandboxSession docstring that every activation write belongs in stage_activation, since close cannot stop a write made before execute. Comments now say close cancels and waits for staging, and that the Codex configuration can carry grant headers rather than always does. Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found no code defect in the staging changes after inspecting all 10 changed files and their affected close, failure, and continuation paths. One validation requirement remains.
RISK — Add representative real smoke-rollout evidence
The PR provides unit-test results but marks real rollouts N/A. This changes observable cancellation and upload-failure behavior in Codex, Pi, and OpenCode, rather than only reorganizing code. The protected AGENTS.md quality bar requires representative real-model smoke rollouts for behavior-changing agent work. The mocked sandbox tests don't provide that integration evidence.
Correction: Run and document a representative sandbox episode for each affected harness with a real model and an MCP grant. Record the configuration, provider, commands, artifact locations, and inspected agent and verifier outcomes in the PR. No runtime rewrite is requested.
Preservation and acceptance: Each episode should initialize and use the granted tool, return the expected response, reach verification, and close with cleanup confirmed. Include a two-activation OpenCode continuation to confirm the resumed session still works. Keep the existing regression assertions for cancellation before release, no launch during interrupted staging, grant-less sessions, and continuation-deadline recovery. Preserve the existing file contents and destinations, including keeping Codex's grant-bearing configuration out of input.json.
This was a static, read-only review; I did not execute tests or rollouts.
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/42678297362 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42680759549 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42682929750 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42685757811 |
What changed
OpenCode, Pi and Codex now upload the files an activation needs inside
stage_activation, which runs insideSandboxSession.execute. Before this change each uploaded some of these files in its response path, before execute.mcp-grants.jsonand the emptymcp-status.json.models.json,settings.json, its extensions,gym_mcp.mjsandmcp-servers.json.home/.codex/config.toml. It stays out ofinput.json, which holds the whole payload.Pi and Codex pass these files to
executethrough a new optionalfilesargument. OpenCode passes its grants in the payload.The
SandboxSessiondocstring now says that every sandbox write an activation needs belongs instage_activation, because close cannot stop a write made beforeexecute.flowchart TD subgraph before["Before"] b1["Response path uploads activation files"] --> b2["SandboxSession.execute"] b2 --> b3["stage_activation writes prompt.txt and params.sh"] --> b4["Harness launch"] end subgraph after["After"] a2["SandboxSession.execute: close fences staging"] --> a3["stage_activation uploads activation files,<br/>then prompt.txt and params.sh"] --> a4["Harness launch"] end b4 ~~~ a2Why
SandboxSession.executeregisters staging so that closing a session stops it before the sandbox is released. Uploads made before execute ran outside that fence. In a single-activation session, closing during them could release a borrowed sandbox, or stop an owned one, while an upload was still writing into it. Pi'smcp-servers.jsonand Codex'sconfig.tomlcan carry the episode's tool session token.Continuation activations were not affected: the agent base joins a continuation activation before it closes the session.
The other harnesses that use
SandboxSessionneed no change. OpenClaw joins an unlaunched activation before it releases the sandbox. Kilo, Hermes, Claude Code, Stirrup, Pool and BrowseComp already stage inside execute.No issue: this came out of the review of #4922, which first moved the OpenCode uploads as part of its image staging. The image part now lives in #4922, so this PR keeps only the change
mainalready needs.Compatibility
No configuration or API change.
prompt.txtstaging already does.prompt.txtfailure already did, so the observations returned at close record the interrupted activation, and OpenCode also reads its MCP status file.filesso that close fences them.Validation
pytest -n 16over the OpenCode, Pi and Codex agent tests passed, apart from tests that fail the same way without this change: the pinned Pi CLI tests need a newer Node than the local Node 20, and a check that the OpenSandbox package is installed fails because that extra is not in the local environment.mainfor single-activation sessions, where the sandbox is released first. The continuation cases already pass onmain.pre-commit run --files <changed files>passed.Rollout evidence
N/A: the change moves existing uploads into the staging step. The same files are written to the same paths before the launch, which the existing tests check through the HTTP session flow.