Repository navigation
Conversation
Add resources_servers/swebench/task_sandbox_sessions.py, a shared helper for SWE resources servers whose seed starts one task sandbox, and use it in swe_gym and r2e_gym. An Environment Server can now seed a typed session, hand the agent the task sandbox through sandbox_access, verify, and close. The legacy seed body and response are unchanged. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
…ML, and SWE internal v1 Use TaskSandboxSessions in swemer_ultra, swemer_oml, and swe_internal_v1, so an Environment Server can seed a typed session, hand the agent the task sandbox through sandbox_access, verify, and close. The legacy seed body and response are unchanged. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
ananthsub
force-pushed
the
ananthsub/swe-typed-sessions
branch
from
October 9, 2026 17:13
e8a8665 to
652d384
Compare
ananthsub
force-pushed
the
ananthsub/swemer-typed-sessions
branch
from
October 9, 2026 17:13
886e260 to
7e97fda
Compare
This was referenced Oct 22, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
This PR makes each server inherit from
SandboxSessionResourcesServer, added in #4302 to the SWEmer Ultra (resources_servers/swemer_ultra, #4116), SWEmer OML (resources_servers/swemer_oml, #3799), and SWE internal v1 (resources_servers/swe_internal_v1, #3933) resources servers. Likeswe_gymandr2e_gymbefore #4302, these servers accept only the legacy flat instance body on/seed_session, so an environment server's typed seed is rejected with a 422, and nothing releases the task sandbox when an episode ends without verify. After this PR, each server serves environment server episodes with the same behavior #4302 describes, while the legacy request and response stay unchanged.The change to each server's
app.pyis the same:SandboxSessionResourcesServerinstead ofSimpleResourcesServer.seed_sessionaccepts either body. AResourcesSeedSessionRequestgoes toseed_task_sandbox_sessionwith the server's own instance model, and the legacy body follows the same steps as before._start_task_sandbox, which registers the sandbox as soon as it exists and returns the agent's working directory. The working directory is the row's ownworkdir._forget_task_sandbox_statedrops the per-session state that seeding records (the untracked files the image ships and the base commit), so a close or an expired session releases it.verifymarks a typed session's sandbox as consumed before it captures the patch, so a repeatedverifyfails instead of grading an empty patch, and the stop at the end of patch capture goes through_release_task_sandbox, so a failed stop leaves the sandbox for close to retry.Each server also gets
tests/test_sessions.py, which runs a typed episode (seed, verify, repeated verify, close), a legacy seed and verify, and the session conformance check through the real server with a fake sandbox, using the first row of the server'sdata/example.jsonl.Issue
No issue is linked. This continues #4302, which adds typed resources sessions to the SWE servers sdevare-nv added.
Stack position
Based on #4302; review that PR first. A sibling PR based on the same branch migrates the six SWE training servers from #3327.
Validation
NEMO_GYM_EXTRA_ROOTS=$PWD PYTHONPATH=$PWD python -m pytest resources_servers/swemer_ultra/tests resources_servers/swemer_oml/tests resources_servers/swe_internal_v1/tests resources_servers/swebench/tests/test_sandbox_sessions.py tests/unit_tests/test_session_contract_repo.py -qpassed.app.py, its tests that use a typed seed fail (the typed seed is rejected with a 422) and its legacy test passes.pre-commit runon the changed files.Rollouts
One SWEmer Ultra task (
getmoto__moto-7365) ran end to end. The run used the same local configuration and setup as the rollouts in #4302:single_agent_turn_legacywithhermes_agent, Docker sandboxes with host networking, Gym's vLLM model server, Qwen3-4B-Instruct-2507 served by vLLM, and a system prompt that tells the model to edit files. These runs check the session plumbing, not solve rate. Hermes ran its terminal commands in the row's working directory inside the task sandbox it received throughsandbox_access; it cloned an unrelated repository there instead of editing moto.verifycaptured exactly that change from the task sandbox (a 211-byte patch adding the clone as a submodule entry), applied it in a fresh sandbox, and completed grading with a reward of 0. The failure sidecar was empty, and no task sandbox was left running after the session closed. SWEmer OML and SWE internal v1 share this seed and verify path, and each is covered by the HTTP-level tests above; their example rows were not run.These rollouts ran before the session code moved from a mixin into the
SandboxSessionResourcesServerbase class and before theoperatescope was added. Neither change alters what runs on Docker: the methods are the same, and the Docker provider ignores the scope.Compatibility
opencode_sandboxed_agentand existing configurations keep working. A legacy seed whose preparation fails now leaves its sandbox registered for shutdown instead of unreferenced.verifyreturns an error instead of a reward of 0.