Repository navigation
feat(openclaw): restrict the egress of agent-created sandboxes - #5557
Conversation
Benchmarks whose Resources server supplies no sandbox, such as HLE, have pi_agent create one per session. pi_sandboxed_agent ran those sandboxes with model-only egress; pi_agent could not, so a reasoning benchmark moved to agent sessions would gain open internet. - network_access (inherit, model_only, model_and_tools) sets an OpenSandbox egress policy on a sandbox the agent creates. A borrowed task sandbox keeps its owner's network, so a session that borrows one rejects any other value. The policy helper, restrict_sandbox_network, lives in nemo_gym.agents.utils.sandbox_network and is exported from nemo_gym.agents so other session agents can share it. - sandbox_runtime_dir points setup at a runtime baked into the image and checks its version, since a model-only sandbox cannot download Node or Pi. Signed-off-by: gwarmstrong <[email protected]>
As for pi_agent: network_access (inherit, model_only, model_and_tools) sets the OpenSandbox egress policy on a sandbox OpenClaw creates, through restrict_sandbox_network from nemo_gym.agents. A session that borrows a task sandbox rejects any other value than inherit, and the setting cannot be combined with sandbox_config.provider_options.network_policy. A model-only sandbox cannot download Node or OpenClaw, so sandbox_runtime_dir points setup at a runtime baked into the image and checks the version its package declares instead of installing; a mismatch fails setup. Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test 5234a7e |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
No code defect found. One required validation-evidence gap remains.
RISK — Supply Pi smoke-rollout evidence for the included changes
The supplied description reports OpenClaw rollouts, but provides no representative Pi rollout evidence for the included network-policy integration and preinstalled-runtime branch. The trusted agent validation requirement calls for real model smoke rollouts when agent behavior changes. OpenClaw results and mocked Pi setup tests don't establish that Pi completes these paths. This is missing evidence, not a demonstrated runtime failure; the uncertainty affects users enabling Pi's new restricted-network/preinstalled-runtime settings.
Correction: Could you link existing Pi results from the preceding PR, or supply representative runs? No code change is requested for this finding.
Acceptance checks: Provide the image, runtime version, relevant configuration and inspected outcomes for:
- An agent-owned OpenSandbox session with a matching preinstalled Pi runtime,
model_only, and no tool grants: model calls succeed, the rollout completes and is graded, and the sandbox is destroyed on close. - A
model_and_toolssession with an MCP grant: the rollout successfully calls the granted tool, is graded, and closes cleanly. Include an egress check showing an unrelated host is blocked.
Preservation: Retain the existing Pi regression assertions: inherit adds no policy; model_only allows only the model host; model_and_tools also allows the grant host; borrowed sandboxes reject restricted modes; explicit policies conflict before creation; matching runtimes skip installation, and mismatched versions fail setup.
I inspected all nine changed files and traced the affected policy, model/tool resolution, runtime execution and cleanup paths. All three delegated inspections reached terminal status; one report wasn't available, so I directly covered its shared-helper, export and test topic. I couldn't execute tests or independently verify the reported rollouts in this read-only review.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
restrict_sandbox_network raised ValueError when a restricted network_access could not be enforced: an explicit provider network policy as well, a provider without network policies, or an endpoint the sandbox cannot reach. The seed route answered it with a 500, which the Environment Server retries, though no attempt can fix the configuration. The helper now raises AgentSeedRejectedError, still a ValueError, so every adapter that calls it refuses the seed once with HTTP 422, before any sandbox is created. Pi also built its tool egress from every MCP grant, including an optional one it leaves out at activation, so such a grant at a loopback URL failed the seed. Egress now covers only the grants Pi keeps. Signed-off-by: gwarmstrong <[email protected]>
…aw egress change Signed-off-by: gwarmstrong <[email protected]>
… with a 422 With NVIDIA-NeMo#5554's restrict_sandbox_network change, a restricted network_access the provider cannot enforce (here an explicit network_policy as well) refuses the seed with HTTP 422 before any sandbox is created, instead of a retried 500. Signed-off-by: gwarmstrong <[email protected]>
|
On the Pi smoke-evidence finding: the Pi changes in this diff are #5554's, which this PR is stacked on, and their rollout evidence is in #5554's description (the Rollouts section): #5554. It covers internal HLE runs of Pi on an agent-owned OpenSandbox with the preinstalled runtime ( This PR now also has #5554's review fix merged in (7b2089b): |
|
/ok to test 61cfd43 |
Both sides added public exports to nemo_gym.agents; both are kept. Signed-off-by: gwarmstrong <[email protected]>
…claw egress change The README conflict kept both new paragraphs: network_access, and the benchmark profile from NVIDIA-NeMo#5550. Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test e041b77 |
Addresses Yu Yao's review of the Pi egress change: - restrict_sandbox_network takes the required tool grants and refuses them under model_only with AgentSeedRejectedError. The policy blocks their hosts, so a session would otherwise fail only after the sandbox and the runtime exist, as a retried 5xx. Pi passes its required MCP grants. - A host written with a trailing dot no longer yields a rule the egress sidecar never matches, and provider_options: null is restricted like an empty mapping instead of raising a 500. - Pi's tests cover both restricted values for a borrowed sandbox, a model URL that fails to resolve (the provider is closed), and a preinstalled runtime that exits nonzero or reports a version prefix. - The profile comment says that with sandbox_runtime_dir: null the image must hold the runtime at the default path with its ready marker. Signed-off-by: gwarmstrong <[email protected]>
Under model_and_tools, a grant at an unreachable address refuses the seed even when optional, and model_only refuses a required grant. Signed-off-by: gwarmstrong <[email protected]>
Signed-off-by: gwarmstrong <[email protected]>
…a 422 Addresses Yu Yao's review: - The preinstalled-runtime check now checks the runtime's Node is 22.19.0 or newer, runs the CLI's --version with a private home (so an incomplete runtime fails at seed, not at activation, and the task's home stays untouched), then compares the version the package declares exactly. A failed check or another version refuses the seed with AgentSeedRejectedError; a transport error or timeout stays retryable. - OpenClaw passes its required MCP grants to restrict_sandbox_network, so model_only refuses them at seed instead of after the 120 s probe. - The README says how to build sandbox_runtime_dir and what the image needs, which grants a restricted seed refuses, that an optional grant still costs a probe under model_only, and that full isolation needs OpenSandbox's dns+nft egress mode. - Tests: several grants plus one declared in the agent config in the egress test, both restricted values for the borrowed refusal, a route test per refusal cause, a runtime-check table (prefix, failed check, timeout), and the exact check command run under a real node. Signed-off-by: gwarmstrong <[email protected]>
Signed-off-by: gwarmstrong <[email protected]> NVIDIA-NeMo#5554 was squash-merged, so its files conflicted with this branch's copy of them; main's versions are kept. This PR's own changes are unchanged.
|
/ok to test 01d0d4f |
Brings in main's latest four commits; this PR's own changes are unchanged. Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test 0c2bcd3 |
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-reviewed at 0c2bcd3 (the change is git diff main...head now that #5554 has merged). Everything from my earlier review is addressed, and CI is green on this head.
- The preinstalled-runtime check now does the installer's ready path plus the floor: Node 22.19.0 or newer,
openclaw.mjs --versionruns with a private home, and the declared version matches exactly.error_typestays a retryableRuntimeError; a failed check or another version is a 422. - Required MCP grants are refused under
model_onlyat seed instead of after the 120 s probe. - A test runs the adapter's exact check command under a real
nodewith a path containing a space, which pins the quoting and the missing trailing newline; the refusal test is parametrized like Pi's. The README covers how to buildsandbox_runtime_dir,bashin the image, anddns+nft.
Not run here: I did not re-run the suites locally; I read the diff and relied on the green CI at this head.
Non-blocking: under model_only an optional grant is still written into OpenClaw's config and can cost up to 120 s of probe before it is dropped. The README now says so, and dropping it fits the one-restricted-mode follow-up in #5552.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42138104061 |
…ent wraps Gym main's #5557 (957a722) wrapped OpenClaw's runtime assignment in parentheses over two lines, so test_a_harness_image_holds_the_runtime_its_adapter_looks_for[openclaw] no longer found it on #5010 merged into main. The pattern now allows an opening parenthesis and whitespace before the expression. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…ent wraps Gym main's #5557 (957a722) wrapped OpenClaw's runtime assignment in parentheses over two lines, so test_a_harness_image_holds_the_runtime_its_adapter_looks_for[openclaw] no longer found it on #5010 merged into main. The pattern now allows an opening parenthesis and whitespace before the expression. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…ent wraps Gym main's #5557 (957a722) wrapped OpenClaw's runtime assignment in parentheses over two lines, so test_a_harness_image_holds_the_runtime_its_adapter_looks_for[openclaw] no longer found it on #5010 merged into main. The pattern now allows an opening parenthesis and whitespace before the expression. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
What does this PR do?
openclaw_agentgainsnetwork_access(defaultinherit) for the sandboxes it creates. The value comes from feat(pi): restrict the egress of agent-created sandboxes #5554'srestrict_sandbox_network, with the Model Server's host and, formodel_and_tools, each MCP grant's host. A session that borrows a task sandbox rejects any value other thaninherit.openclaw_agentgainssandbox_runtime_dir: an absolute sandbox path that holds a preinstalled runtime in the installer'snode/andopenclaw/layout. Setup checks the version its package declares instead of installing, and a mismatch fails setup.Why. The same reason as #5554, for OpenClaw. Without this, a sandbox OpenClaw creates has the provider's default network, and a restricted sandbox cannot download OpenClaw. Stacked on #5554, whose branch this PR targets. Part of #5552.
Validation
gym env test +entrypoint=responses_api_agents/openclaw_agent +should_validate_data=true: 504 passed, 1 skipped. The skip already existed: it needs a real pinned runtime.With the behavior disabled, the new tests fail. That covers model-only and model-and-tools egress, the borrowed-sandbox rejection, both preinstalled-runtime cases, the absolute-path check, and, separately, the version-mismatch case. The
inheritcontrol passes.Review follow-up: feat(pi): restrict the egress of agent-created sandboxes #5554's review fix merged in (7b2089b), so this adapter's
restrict_sandbox_networkcall refuses an unenforceablenetwork_accesswith a terminal 422.test_unenforceable_network_access_is_a_terminal_seed_refusalchecks the 422 and that no sandbox is started. Suite in the adapter's own venv: 505 passed, 1 skipped.pre-commit run --all-files: clean.Follow-up to the feat(pi): restrict the egress of agent-created sandboxes #5554 review: merged its latest head; the helper call passes the provider; a borrowed sandbox with a restricted value is refused with
AgentSeedRejectedError; the README says a borrowed sandbox relies on its owner's policy. Its benchmark profile setsnetwork_access: model_onlyand requiressandbox_runtime_dir. The adapter's owntest_benchmark_profile.pyexpectsmodel_only(removing it fails the test). Suite: OpenClaw: 507 passed, 1 skipped; profile and helper tests pass.Review follow-up (Yu Yao) at 83fd017: the preinstalled-runtime check verifies Node 22.19.0+, runs the CLI with a private home, and compares the declared version exactly; a failed check is a 422, a timeout stays retryable; required MCP grants are refused under
model_only; README on buildingsandbox_runtime_dir. Tests: a runtime-check table, the exact check command under a real node, route refusal tests per cause, a configured grant in the egress test. OpenClaw suite with the profile and helper tests: 547 passed, 1 skipped.Rollouts
On the internal OpenSandbox deployment used for #5554's egress checks, before this PR's review changes, an image with OpenClaw 2026.6.11 preinstalled under
/opt/openclaw-runtimereported its version with egress limited to the model and tool hosts, whilenodejs.org, the npm registry and GitHub's DNS name were blocked.Internal runs on the
georgea/nemo-gymfork at ee833ed, which carries this change before its review updates (Nemotron 3.5 Super on vLLM, 5 text tasks each, that image):model_only: 5/5 rollouts completed, graded and healthy.model_and_toolsand Gym's Tavily server: 5/5 healthy, with the search tools called in 3 of 5.model_only: 5/5 healthy.Compatibility and benchmark impact
Defaults unchanged:
network_access: inheritand nosandbox_runtime_dir.The adapter's own default stays
inherit. Its benchmark profile (from #5550) now setsnetwork_access: model_onlyand requiressandbox_runtime_dir, so a run that uses the profile gets the restricted sandbox; open-network scores are not comparable.Coordination with #5379. #5379 uploads the
provider_pluginfiles right after the installer, and this PR moves the installer into theelse:ofif sandbox_runtime_dir. Whichever PR merges second must run those uploads after the wholeif/else, or a preinstalled runtime skips them; a text merge alone will not catch it.Checklist
pre-commit run --all-files).git commit -s).