Skip to content

feat(sandbox): sandbox server for cross-server sandbox sharing - #2081

Closed
ananthsub wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ansubramania/sandbox-server
Closed

feat(sandbox): sandbox server for cross-server sandbox sharing#2081
ananthsub wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ansubramania/sandbox-server

Conversation

@ananthsub

@ananthsub ananthsub commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a sandbox server, a fourth composable Gym server type (sandbox_servers/) that owns physical sandboxes and lends them across servers by reference. A box created by one server (an agent running a rollout) can be operated by another (a resources server that scores it): either the same live box, or a fresh eval box the verifier creates. It is standalone and does not depend on any agent.

Changes

  • ConnectableProvider — an optional runtime_checkable capability protocol (serialize_handle / connect), separate from the base SandboxProvider, which is unchanged.
  • AsyncSandbox.serialize / AsyncSandbox.connect — facade methods that use the capability. serialize(scope="operate") produces a co-lease descriptor; connect(descriptor, provider=...) rebuilds a started sandbox in another process.
  • RemoteSandboxProvider — forwards the provider protocol to a sandbox server over an injected SandboxHttpTransport, so nemo_gym.sandbox never imports the server framework (no dependency cycle).
  • SandboxRef — a serializable, signed lease capability (server_url, sandbox_id, scope) that travels in a request body. Owner leases may destroy the box; operate co-leases may not. Leases are bound to the rollout id.
  • Direct reattach for the OpenSandbox provider (Sandbox.connect(id)), so external-control-plane providers can be shared without standing up a sandbox server or paying an extra network hop.
  • nemo_gym.sandbox_client — the single bridge that injects Gym's aiohttp client (make_remote_provider, connect_sandbox).
  • sandbox_servers/sandbox_server — the server (create/exec/upload/download/status + lease grant/release, in-process registry, max_concurrent admission, TTL reaping, teardown on shutdown) and registration of the fourth server type in config_types.py.

Test plan

  • tests/unit_tests/test_sandbox_server.py (new), hermetic with a fake in-process provider:
    • SandboxRef serialization and scope.
    • Direct reattach with no server (serialize -> connect).
    • serialize rejects a provider without the connect capability.
    • Full in-process HTTP round-trip against the real server app (via httpx ASGI transport, test-only): create, exec, upload/download, status, owner and operate serialize, co-lease connect, bad-lease rejection, release keeps the box alive, owner close.
  • Existing sandbox and config-type tests pass; ruff clean.
  • Sandbox library confirmed free of server_utils imports.

Add a fourth Gym server type (sandbox_servers/) that owns physical
sandboxes and lends them across servers by reference, so a box created by
one server (e.g. an agent running a rollout) can be operated by another
(e.g. a resources server that scores it): attach to the same live box or
spin up a fresh eval box.

- SandboxRef: a serializable, signed lease capability (server_url,
  sandbox_id, scope) that travels in a request body; owner leases may
  destroy the box, operate co-leases may not. Leases bind to the rollout id.
- ConnectableProvider: an optional runtime_checkable capability protocol
  (serialize_handle/connect) separate from the base SandboxProvider.
- AsyncSandbox.serialize/connect: facade methods that use the capability.
- RemoteSandboxProvider: forwards the provider protocol to a sandbox server
  over an injected SandboxHttpTransport, so nemo_gym.sandbox never imports
  the server framework.
- Direct reattach for the OpenSandbox provider via Sandbox.connect(id), so
  external-control-plane providers can be shared without a sandbox server.
- nemo_gym.sandbox_client: the one bridge that injects Gym's aiohttp client.
- sandbox_servers/sandbox_server: the server, config, and fourth-server-type
  registration in config_types.

Hermetic tests use a fake in-process provider to drive both the direct
reattach path and a full in-process HTTP round-trip against the real server.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

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.

@ananthsub
ananthsub requested a review from hemildesai July 20, 2026 15:23
@ananthsub ananthsub linked an issue Jul 20, 2026 that may be closed by this pull request
@ananthsub
ananthsub requested a review from cmunley1 July 20, 2026 15:36
@ananthsub

ananthsub commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the PR stack here for easier review: #2083

@ananthsub ananthsub closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox server to share sandbox states needed for rollouts

1 participant