Repository navigation
fix(litmus_agent): release the sandbox through the shared session hooks - #5482
Merged
Merged
Conversation
…sion With sandbox_provider set, litmus_agent starts a per-rollout sandbox keyed by the session cookie, and stopped it only in the wrapped /verify or at shutdown. Under single_agent_turn_legacy, an episode that never reached /verify kept its sandbox until the provider TTL (OpenSandbox) or server shutdown (Apptainer), because the inherited close_resources_session kept no state. _cleanup_session also dropped the session before stopping it and swallowed stop errors, so a failed stop leaked the sandbox. - seed_session binds a typed seed's resources_session_id to the cookie and records its episode and task; the legacy /run seed body keeps no state. - close_resources_session stops the sandbox by resources_session_id, fences late seeds with ResourcesSessionFence, is idempotent, and raises when the stop fails, so the caller can retry. - A sandbox whose stop fails stays registered so a later cleanup retries it; verify logs the failure and keeps its score, and shutdown goes on to the remaining sandboxes. - A tool call for a closed session gets ResourcesSessionLostError (404); a call that a close overtook stops the sandbox it started. - A /verify for a closed session returns lost_session_verification. - Drop the shared litmus-no-session fallback key. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test a5e35cf |
This was referenced Nov 3, 2026
yaoyu-33
marked this pull request as ready for review
November 3, 2026 18:33
Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…ping it Verify's cleanup ran without the session's lock, so a verify that arrived while the first tool call was still creating its sandbox stopped a wrapper with no handle yet: that only released the client. Startup then created the container, which nothing tracked or stopped. A close could likewise stop a sandbox under a running cell, so the call failed with a 500 instead of finishing. _cleanup_session now holds the session's lock across the stop, and a tool call that waited behind a cleanup gets 404. The post-exec closed check could no longer fire, so it is gone; its test is replaced by tests that drive a real close during a cell and a real verify during startup, both of which fail on the previous code. The conformance import moves to nemo_gym.server_runtime.testing, and the README notes OpenShell's queued deletes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 5678ae6 |
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…ycle - The repo contract test counts a server that implements the state hooks as closing through the inherited close_resources_session. newton_bench, workplace_assistant, tavily_search and indirect_prompt_injection override seed_session but close through the hooks, and failed it. - Export reject_partial_typed_seed from nemo_gym.server_runtime, so servers that override seed_session reuse the shared guard instead of a copy. - The MCP seed wrapper still recognises a request param annotated as Annotated[Request, ...]; keeping Annotated metadata had made it inject a second Request and fail with KeyError. - Name the 409 for a typed seed over a cookie session "cookie-seeded", not "legacy", and document that a served seed_session override declares request before body. - Shared tests now cover the MCP-wrapped seed route, close after verify (checked against the verified episode), and a cookie seed of a verified typed session. - The add-benchmark skill describes the three state hooks as the default for a stateful server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…nt cookie sessions - Stop the remaining sandboxes concurrently at shutdown. The server supervisor kills the process about a second after SIGINT, so stopping them one at a time left most of them to their ttl_s. A failed stop is still logged with its session ID and does not keep the others from stopping. - Test that shutdown stops sandboxes concurrently, and that a shutdown during a pending sandbox start waits for the start, stops the started sandbox, and fails the waiting tool call as a lost session. - README: shutdown stops what it can within the shutdown grace and leaves the rest to ttl_s; after a cookie session's /verify a tool call on that cookie gets 404 until the cookie is seeded again; a cookie seed of a closed session gets 409. - Tests import check_resources_session_contract and ResourcesParticipant from nemo_gym.server_runtime, which test_public_api_facades requires. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
The docs now describe only the typed Environment Server path. The cookie seed still works unchanged; the PR description records that compatibility. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 4022766 |
Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test d9a8df6 |
Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test ca13157 |
Preserve the shared session cleanup logger and the multiworker FastAPI entrypoint from main. Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 2934bed |
cmunley1
approved these changes
Nov 13, 2026
cmunley1
enabled auto-merge
November 13, 2026 01:12
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43343355024 |
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.
Release Litmus sandbox state through the shared resources lifecycle from #5709. Verification uses the base-registered route and its tracing, grading observations, and judge-failure handling, including verifier-only configurations without a sandbox provider. Direct
verify(body)callers retain request-only grading.The shared lifecycle in #5709 and MCP support in #5708 are merged into main. This PR contains only the Litmus migration and related tests/documentation. No separate issue is needed for this focused migration of an existing resources server.
retain(None)) because the request carries the answer and grading data.Validation
Final Litmus source at
ca1315764, on workstationws, Python 3.13.14, with the validation checkout first onPYTHONPATHandNEMO_GYM_EXTRA_ROOTS:python -m pytest -o addopts='' -o log_cli=false resources_servers/litmus_agent/tests -q --tb=short: 112 passed.pre-commit run --all-files: passed in the combined validation checkout, including Ruff, formatting, guardwords, configuration checks, README generation, and import layering.git diff --checkpassed. New commits include DCO sign-off.nvidia/nemotron-3.5-lightning-30b-a3b: the model returned((3)); the base verification route scored 1.0, unmasked, emitted a completed grading record bound to the response and score, and released typed identity. Close succeeded. Both changed Litmus files matched the committed source hashes before and after the run. This smoke exercises the changed verifier-only route; it does not start a sandbox or establish benchmark parity.56c33f3705f5669705d432e1c8e53e885d07ac6aused the same model, produced Python output 385 through two real tools, scored 1.0 unmasked, and released all session/identity state. That evidence is historical; the latest route refactor did not change sandbox execution.The branch includes main at
acb67734c. The earlier combined refresh passed all nine environment suites (904 tests) and shared lifecycle/MCP/process-supervisor checks (213 tests); those counts describe that earlier validation, not the latest focused run. These checks do not replace the current repository CI matrix or review approval.