Repository navigation
feat(swe): opt-in swe_agents container setup for swe_rebench and swe_internal_v1 - #6173
Conversation
The Apptainer swe_agents harness gave both the agent's container and the evaluator's container a Maven/Gradle mirror, a Chrome wrapper for Karma (--no-sandbox --disable-dev-shm-usage, needed as root with a small /dev/shm), and _JAVA_OPTIONS, GRADLE_USER_HOME, DOTNET_GCHeapHardLimit, CHROME_BIN and CHROMIUM_BIN. swe_rebench sets only GRADLE_USER_HOME and ships the mirror to eval sandboxes only, so a run moved from that harness trains and grades in a different toolchain environment. Add resources_servers/swebench/legacy_container_setup.py and apply it to the agent and eval sandboxes of swe_rebench when sandbox_config sets legacy_container_setup: true (default off). Environment variables go through SandboxSpec.env, and explicit sandbox_config.env keys still win. Files go through SandboxSpec.files: an eval sandbox's verification files win on shared paths, and the mirror uses the same paths as swe_rebench's verification files so it is installed once. A setup exec marks the wrapper executable and copies the Gradle init script to the other Gradle homes the harness covered; if it fails, the sandbox is stopped. The Apptainer-only steps (the /etc/hosts rewrite and /var/run/postgresql) are not carried over. overwrite_maven_settings: false also keeps settings.xml out of the added files, so a provider's read-only settings.xml is left alone in both sandboxes. 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. |
…on chmod Rename the module to swe_agents_container_setup.py and its names after the harness they copy. The config key stays legacy_container_setup because existing training recipes set it. The setup command now fails when it cannot make the Chrome wrapper executable. Before, the command always exited 0, so Karma failed later and the row scored 0 instead of being reported as a failed setup. The Gradle init script copies are still best effort. The _JAVA_OPTIONS comment now says preferIPv6Addresses is kept to match the harness, and that swe_rebench measured no effect from it. Signed-off-by: Ananth Subramaniam <[email protected]>
The setup command test ran the real mkdir under /home, which creates directories on the host when tests run as root. Point both Gradle homes at tmp_path, and check that the init script is copied to the writable home while the unwritable one still lets the command succeed. Signed-off-by: Ananth Subramaniam <[email protected]>
Asserting that no /home/ path remains failed falsely when TMPDIR is under /home. Check the two home paths the command uses instead. Signed-off-by: Ananth Subramaniam <[email protected]>
Apply the swe_agents container setup to swe_internal_v1's agent and eval sandboxes when sandbox_config sets legacy_container_setup: true, as swe_rebench already does. Training recipes set the key for both servers through a shared anchor, and until now swe_internal_v1 ignored it. swe_internal_v1 has no overwrite_maven_settings option, so it always ships the Maven settings. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
…rk loans swe_internal_v1 goes back to its mapping sandbox_config: PRs #5656 and #6173 read new keys from it with .get(), so it moves to the stage after they merge. LentSandboxes now refuses network_access no_network, since the harness in a lent sandbox calls the model server, and SandboxNetwork's validator returns Self. 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 confirmed runtime defect in the setup, precedence, or retry/cleanup paths. The remaining RISK is the missing model rollout through swe_internal_v1, described inline.
NOTE, documentation suggestion: Could you document the option outside the PR description? Neither server's running guide exposes it: swe_rebench or swe_internal_v1. Users migrating recipes need a persistent reference for this behavior-changing startup option.
Add a short Fern section linked from both READMEs with sandbox_config.legacy_container_setup: true nested under each resources-server configuration. Explain that it defaults to false, affects agent and evaluator sandboxes, and lets explicit environment values win. Distinguish the servers: overwrite_maven_settings: false is a server-level option in swe_rebench, while swe_internal_v1 always supplies the Maven settings when setup is enabled. Keep the feature opt-in and describe failed setup as infrastructure failure, not a completed task failure. Static acceptance: compare both documented examples and precedence statements with the two _create_sandbox implementations; no runtime change is requested.
I inspected all six changed files and traced their affected sandbox lifecycle and verification paths. I did not execute tests in this read-only review.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| self._verifier_sandboxes[verifier_session_id] = sandbox | ||
| await sandbox.start(spec) | ||
| if swe_agents_setup: | ||
| await sandbox.start_with_setup(spec, apply_swe_agents_container_setup) |
There was a problem hiding this comment.
RISK: finish the model smoke rollout through swe_internal_v1. The description explicitly leaves this run open. Its golden-patch run exercises evaluator creation, but skips the agent path through _start_task_sandbox, model tool execution, and patch capture. The new recording sandbox also stores the setup callback without executing it. This leaves the newly enabled agent environment unvalidated for this server. It is a validation gap, not a confirmed runtime failure.
Could you run one representative supported row end to end with a real model and legacy_container_setup: true, as required for behavior-changing environment work by AGENTS.md? Record the command, provider, model, row, and inspected outcome. Acceptance: agent setup succeeds, its tool commands see the configured environment and executable wrapper, its patch reaches verification in a fresh sandbox, and verification completes without infrastructure masking. Reward may be 0 for an incorrect model patch; it need not be 1. Confirm both sandboxes are cleaned up. Keep the existing golden-patch and swe_rebench rollout evidence; no production-code rewrite or default change is requested.
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed f4195bc; no blocking source defect found, including an independent review.
Completed the missing swe_internal_v1 integration smoke on a workstation using the repository's public getmoto__moto-5949 fixture, the default OpenCode session route, Docker, and deepseek-ai/deepseek-v4.1-flash through Gym's openai_model. Set sandbox_config.legacy_container_setup: true and is_verifying_golden_patch: false.
- The model's own shell output confirmed all five setup environment variables, the executable Chrome wrapper, Maven settings, and all three Gradle mirror copies.
- Captured a 2,130-byte model worktree patch, distinct from the golden patch. A separate evaluator sandbox applied it; all four required tests passed: reward
1.0,evaluation_completed: true,mask_sample: false, no verifier error. - Both sandboxes passed setup inspection and were removed; session close and collector shutdown completed.
Qualification: the agent reached its configured 900-second execution budget after producing its edits and returned incomplete/timeout. Patch capture, verification, and cleanup still completed. This validates the affected integration path using the public fixture, not the private training delivery.
Invocation (paths shortened):
gym eval run --config run.yaml --output rollouts.jsonl --concurrency 1 --split benchmark --num-repeats 1The flagged rollout-evidence gap is covered. Current CI has no failed or pending checks.
Keep the legacy container setup tests and the pinned log parser tests in resources_servers/swe_rebench/tests/test_app.py. Signed-off-by: svcnemo-autobot <[email protected]>
|
/ok to test feccaf8 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43960582323 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43972659243 |
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test cb0cbfa |
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed cb0cbfa; no blocking issue found, including an independent recheck.
The merge-queue failure came from test config stubs missing sandbox_provider_options after #6177. The fixtures now instantiate the real server config models; all assertions and production behavior are preserved.
Validation on ws: 144 tests passed on the PR revision, 162 passed on the failed merge-group revision with this repair, all 31 benchmark-preparation tests passed, and pre-commit run --all-files passed. The separate core-test hang did not reproduce. The runtime setup code is unchanged from f4195bc; I rechecked the existing model-smoke and cleanup evidence recorded in the earlier review: #6173 (review) . No new model rollout was needed for this test-only repair.
Fresh CI is running at this exact head: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43979466816 . Approval does not assert that the pending CI or merge queue has passed.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43985742488 |
What changed
swe_rebenchandswe_internal_v1gain an opt-insandbox_config.legacy_container_setupflag (defaultfalse). When it istrue, both the agent sandbox and the eval sandbox get the toolchain setup that the Apptainerswe_agentsharness applied to its agent and evaluator containers:_JAVA_OPTIONS(IPv4 preference and the Robolectric Maven mirror URL),GRADLE_USER_HOME,DOTNET_GCHeapHardLimit(8 GiB), andCHROME_BINandCHROMIUM_BIN, which point at the Chrome wrapper. Explicitsandbox_config.envkeys still take precedence.settings.xmland Gradle init script mirror, plus a Chrome wrapper that runs the image's real Chrome with--no-sandbox --disable-dev-shm-usage. An eval sandbox's verification files take precedence on shared paths. The mirror uses the same paths as the verification files, so each file is installed once./home/gradleand/home/user. If the wrapper cannot be made executable, the setup fails; the extra Gradle copies are best effort. The server usesAsyncSandbox.start_with_setup, so a failed or timed-out setup stops the sandbox. The eval path then retries on a fresh sandbox._JAVA_OPTIONSkeeps-Djava.net.preferIPv6Addresses=falseto match the harness, thoughswe_rebenchmeasured no effect from it.The setup lives in
resources_servers/swebench/swe_agents_container_setup.pyso that other sandbox SWE servers can reuse it. The code is named after the harness it copies. The config key keeps the namelegacy_container_setupbecause existing training recipes set it. The Apptainer-only steps, rewriting/etc/hostsand creating/var/run/postgresql, are not carried over.In
swe_rebench,overwrite_maven_settings: falsealso applies to the added files. With that setting, neither sandbox getssettings.xml, so a provider's read-only copy stays in place.swe_internal_v1has no such option and always ships the Maven settings, as the harness did.Why
Without the flag,
swe_rebenchsets onlyGRADLE_USER_HOMEand sends the mirror files to the eval sandbox only, andswe_internal_v1sets none of it. A training run moved from the Apptainer harness therefore runs the agent in a different toolchain environment. For example, Karma suites cannot start Chrome as root with a small/dev/shm, and, where the agent sandbox has open egress, the agent's Maven builds cannot reach Maven Central. Under an egress policy that allows only the model endpoint, the agent sandbox cannot reach the mirror either. The Chrome wrapper,DOTNET_GCHeapHardLimitandGRADLE_USER_HOMEstill apply. Training recipes setlegacy_container_setup: truefor both servers, through a shared config anchor, to get the old behavior back. Server configs drop unknown keys without a warning, so until this lands those recipes run without the setup.Related PRs
#5656 also ships a Chrome wrapper and setup to
swe_rebenchandswe_internal_v1sandboxes, through new genericsandbox_config.filesandsetup_commandkeys. It does not readlegacy_container_setup, so recipes that set this key need this change. Merging both would give Gym two ways to ship the same files to the same sandboxes. This PR replaces the setup half of #5656 and keeps the key the recipes already use.Issue
No issue is linked: this change restores container behavior that existing training recipes rely on.
Tests
settings.xml), the setup command it runs, and that a failed or timed-out setup raises. They also run the real setup command throughsh: it fails when the wrapper cannot be made executable, and it succeeds when the other Gradle homes are missing. They also run the Chrome wrapper against a stub binary to confirm it passes the container flags first, then the caller's arguments.swe_rebenchserver tests check that:overwrite_maven_settings: falsekeepssettings.xmlout of the agent sandbox;swe_internal_v1server tests check that the setup is off by default, that the agent sandbox gets the environment variables, the files and the setup step with the flag on, and that an eval sandbox keeps its verification files.Commands run:
Rollout evidence
Smoke runs with
legacy_container_setup: trueran locally from a workstation against a remote OpenSandbox cluster, with a hosted model behind Gym'sopenai_modelserver. They used three rows:swe_rebenchcqfn__diktat-932(Kotlin, Maven)swe_rebenchvideo-dev__hls.js-6692(TypeScript, Karma)swe_internal_v1getmoto__moto-5949(Python)Agent sandbox. For each
swe_rebenchimage, I created a sandbox throughSWERebenchResourcesServer._create_sandboxon OpenSandbox and inspected it. This is the same call that seeds an agent session. In both sandboxes:CHROME_BINandCHROMIUM_BINwere/tmp/chrome-wrapper.sh, and the wrapper was executable._JAVA_OPTIONS,GRADLE_USER_HOME=/root/.gradleandDOTNET_GCHeapHardLimit=0x200000000were set./root/.m2/settings.xmlmirroredcentralonly.nemo_gym_mirror.gradlewas present in/root/.gradle/init.d,/home/gradle/.gradle/init.dand/home/user/.gradle/init.d.On the JVM image,
javaandmvnprintedPicked up _JAVA_OPTIONS, andjava.net.preferIPv6Addresseswasfalse. On the Karma image,$CHROME_BIN --headless --dump-domrendered a test page.Eval sandbox. I ran golden-patch verification through
gym env startandgym eval runwith the flag on for both servers:cqfn__diktat-932Picked up _JAVA_OPTIONSand Maven resolving from the Google mirror.video-dev__hls.js-6692getmoto__moto-5949swe_internal_v1.Evaluation completed for every row, and no setup step failed.
Agent rollout. OpenCode ran one
swe_rebenchrow end to end with the flag on, through theswe_rebench.yamlOpenCode route. Gym's Docker sandbox provider ran on the workstation withnetwork: host, so OpenCode inside the container reached Gym's model server on127.0.0.1. The model wasopenai/openai/eccn-gpt-6-lunaon the NVIDIA inference API, behindopenai_model. The inference key stayed in the model server on the host.cqfn__diktat-932PASS_TO_PASStests passed.LineLengthFixTest(FAIL_TO_PASS) still failed, so the model's fix was wrong.Inside the running agent container,
CHROME_BINpointed at the executable wrapper, andGRADLE_USER_HOMEandDOTNET_GCHeapHardLimitwere set.nemo_gym_mirror.gradlewas present in all three Gradle homes. OpenCode's ownmvncalls printedPicked up _JAVA_OPTIONS, which shows the agent's tool calls ran in the container with the setup applied.apply_swe_agents_container_setupreported no failure.Still open: an agent rollout through
swe_internal_v1. That server's setup is covered by unit tests and the golden-patch run above.Compatibility
Default behavior is unchanged. The flag is off unless a config sets it.