Repository navigation
feat(sandbox): expose the shared OwnedSandboxes owner - #6414
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. |
A client that disconnects cancels its request, and every later await in it. An unshielded stop in the request's cleanup then raises before the provider closes the sandbox, which runs on until its ttl_s. nemo_gym.sandbox.stop_sandbox(), in the sandbox package's utils, shields the stop from that cancellation and bounds it in time, so a hung provider cannot hold the request either. A timed-out stop raises TimeoutError, which owners treat like any other failed stop. It also accepts a Compose group, which harbor owns. LentSandboxes, the swebench sandbox session base and deepswe_external1 each had a copy of this stop; they now use the shared one. Signed-off-by: Ananth Subramaniam <[email protected]>
Every sandbox has one owner, the server that starts it, but each server
family owns its sandboxes through its own design. Gym already has a class
that tracks a server's sandboxes by key, stops them, lends them with operate
scope and snapshots them for checkpoints: SandboxSessionCheckpointer, which
no server uses yet.
It becomes the public nemo_gym.server_runtime.OwnedSandboxes, in its own
module (nemo_gym/server_runtime/owned_sandboxes.py) since it is no longer
checkpoint-only, and every SimpleServer holds one as self.sandboxes:
- created on first use from the server's sandbox_provider and
checkpoint.state_dir, so a server without sandboxes builds nothing
- self.sandboxes.on("<field>") gives the instance for a second provider
field, with its own server name for the snapshot index
- run_webserver wraps the app's lifespan so the shutdown stops what every
instance still owns, after the server's own shutdown code
- access() lends through the provider block the instance was built from
- the instance owns the provider it creates and closes it once every
sandbox is stopped; it reads the config the server was started with
- the shutdown sweep runs after the server's own shutdown, is bounded
(150 s in all), refuses to build new instances once it began, and is
documented next to server_shutdown_timeout_seconds
The glossary gains "sandbox owner" and "lend / borrow", and its existing
"Owner" (the worker that holds a session) points away from them.
The class is renamed directly without an alias: it merged on 2026-11-16 and
is in no release.
Signed-off-by: Ananth Subramaniam <[email protected]>
c4b8ae6 to
d72fc64
Compare
Resolve against main: - Drop this branch's earlier copy of the shielded stop (stop_sandbox() in nemo_gym.sandbox.utils and its test): #6410 merged a different version that puts the shield and limit in AsyncSandbox.stop(timeout_s=...). The sandbox package, LentSandboxes, the swebench session base and deepswe_external1 take main's code; OwnedSandboxes stops through AsyncSandbox.stop. - #5266 exports the checkpointer under its old name: its server, conformance helper and test move to OwnedSandboxes in owned_sandboxes, and the public API serves SandboxCheckpointConfig, SandboxCheckpointError and checkpoint_state_dir from there. No release shipped the old name. - The glossary keeps main's sandbox lease and capabilities rows beside the owner and lend/borrow rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
OwnedSandboxes.for_server created the provider before it read checkpoint.state_dir, so a refused config (checkpointing on without a state_dir) left a provider nobody closes, and every later self.sandboxes built another. The provider block and state_dir are now resolved first. An owner on the local provider, which runs commands as host processes, logs a warning. The self.sandboxes docstring and the glossary say what is true today: no server owns its sandboxes through it yet, it is used from the event loop, and a borrower is an agent or a Resources Server grading in the sandbox. The test imports names from their defining modules. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test ed01ab7 |
|
Review of d72fc64, as the bottom of the stack (#6415, #6416 and #6417 have their own comments). The behavior this PR adds works, including on a live OpenSandbox. I would hold it for the restack plus items 1 and 2 below. Each finding says whether I confirmed it with a test or run, or only read it from the code. For the whole stackA. The stack does not merge onto
B. One repo-wide test fails on every head of the stack and passes on the base. Confirmed: C. The split reads well. Each head works without the one above it. This PR alone exposes D. Nit. New lines across the stack use This PR1. High: the rename removes a name that 2. Medium: drop the earlier shared stop when restacking. Read from code. 3. Low: a misconfigured provider shows at the first request, not at startup. Read from code, and the description says so. The new tests assert real behavior against a fake provider (lazy creation, shutdown order, the sweep's budget, provider close). What I ran on d72fc64
|
|
Follow-up to the review and verification record above, at
|
…-sandboxes' into codex/ready-6414 Signed-off-by: yaoyu-33 <[email protected]> # Conflicts: # nemo_gym/server_runtime/owned_sandboxes.py # tests/unit_tests/server_runtime/test_owned_sandboxes.py
…x/ready-6414 Signed-off-by: yaoyu-33 <[email protected]> # Conflicts: # nemo_gym/server_runtime/base_server.py
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Re-review at 1f7f667Tracking issue: #6703 I reread the commits pushed since my last comment and reran the live checks on this head. No new finding on this PR. Addressed
Still open, low
Live check on this head: 19 of 19 pass against OpenSandbox (lazy creation, create, lend to a borrower, the shutdown sweep, then export, restore from the snapshot and release), and no sandbox was left. The two regressions I found in this round are in #6416's merge, not here. |
…and others borrow it The owner description named a Resources Server as a lender of the attempt's sandbox on equal terms with the Environment Server. The Environment Server owns the sandbox an attempt runs in and lends it to the agent and to the Resources Server; a Resources Server owns a sandbox only for a grader that runs code in an attempt without one. Today's Resources lenders and agent-owned harness sandboxes are described as what moves onto it. An export also waits for borrowers' commands, not only the owner's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test f053fa5 |
Resolve an explicitly configured sandbox_provider while loading the server config so an absent named block stops launch before a rollout is dispatched. Preserve defaults used by optional backends and keep provider construction lazy. Report only the type when a reference points at a scalar setting. Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test e0c862c |
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed the sandbox owner lifecycle, checkpoint import compatibility, SWE-bench integration, and startup validation at e0c862c28.
I ran the one-row DeepSWE/OpenCode eval with sandbox_provider: sandbxo. Previously all four servers reported ready and the first seed failed. With the fix, the resources server reports the missing named block at startup, before rollout dispatch. Omitted optional defaults and inline provider settings retain their existing behavior.
Full pre-commit passed. The affected server runtime, sandbox, public API compatibility, and SWE-bench checkpoint suites reported 1,540 passed and 3 skipped. The negative eval stops before model inference. The new head’s CI is running.
Allow standalone server schemas to be inspected before the operator composes a provider block. Check the reference before launching a worker or returning from a dry run. Exercise both the schema-only load and actual startup with the same configuration. Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test c46c9f4 |
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed the sandbox owner lifecycle, checkpoint compatibility, and the revised launch check at c46c9f4ea. Standalone recipes can still load before composition. When a server starts, Gym resolves its explicitly named provider against the composed config.
I ran the DeepSWE/OpenCode eval with one real task and the Docker provider. With sandbox_provider: sandbxo, the resources server reported the missing block before rollout dispatch. With sandbox_provider: sandbox, all four servers reached ready. The positive check covered startup only.
The workstation suites covering server runtime, sandbox, SWE-bench checkpoints, public APIs, and CritPt passed 3,590 tests with five skips. Full pre-commit passed.
The CI shard containing CritPt also passed. Two other server shards need a retry after GitHub refused dependency downloads for IFBench and NOOA during setup.
Third review round at c46c9f4Tracking issue: #6703 I read the three commits pushed since my last comment and reran the live check on this head. Addressed
New, low: this is a behavior change worth a line in the compatibility notes. (read from code, and counted) The launch check also runs in a dry run. 107 shipped configs name Live check on this head: 19 of 19 pass against OpenSandbox, and no sandbox was left. No other finding on this PR. |
hemildesai
left a comment
There was a problem hiding this comment.
Approving at c46c9f4. Three review rounds, the live OpenSandbox check (19 of 19) and pre-commit on this head; my findings on this PR are addressed. Details are in my comments above and in #6703.
One low item stays open and does not block: a server now resolves an explicitly named sandbox_provider when it launches, which deserves a line in the compatibility notes.
The failing CI checks are the ones marked non-blocking: the mini-SWE sandboxed conformance probe fails wherever it currently runs, including on main and on other open PRs.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/45564126056 |
Expose
nemo_gym.server_runtime.OwnedSandboxesas the shared owner of a server's sandboxes.SimpleServer.sandboxesbuilds it lazily from the server's provider configuration;.on("provider_field")selects another provider with a separate checkpoint index.server → OwnedSandboxes → create / lend / stop / checkpointThe server's lifespan stops remaining owned sandboxes and closes their providers after its own shutdown, within the shared 150-second sweep budget. Checkpoint storage is initialized when configured; an owner that never exports needs no snapshot directory. Secondary provider fields use separate index directories and snapshot-name hashes, including when another server has a similar name. Failed or cancelled provider closes can be retried, and concurrent closes serialize.
The former
SandboxSessionCheckpointername and_checkpoint.sandboxmodule remain available with deprecation warnings. Invalid provider configuration is refused before a provider is created. No benchmark recipe is migrated in this PR; the SWE-bench checkpoint integration uses the new public name.Stack
Review bottom to top: #6414 → #6415 → #6416 → #6417. Each PR targets the preceding branch; #6414 targets
main. The stack includesmainthroughd80581feb. Follow-up adoption and remaining lifecycle limits are tracked in #6703.Validation
On the workstation, at
1f7f667ca:pre-commit run --all-files: passed, including import layering and formatting.Preparation commits include DCO sign-off. Model rollout: N/A for this shared ownership API and rename; no new agent or verifier policy is adopted. The complete stack also has the real Docker lifecycle smoke recorded in #6417. Cloud-provider lifecycle behavior has not been rerun in this validation.