Repository navigation
feat(swe): block egress from the agent's sandbox in the SWE servers - #6177
Conversation
With open egress, RL agents learn to fetch the task's upstream fix: newer package releases, or the fixed source from GitHub, through any runtime. swe_rebench, swemer_v1, swemer_v2, swemer_oml, scale_swe and swe_next create the agent's sandbox in seed_session and hand it to the agent, so the agent's own network_access cannot put a policy on it. Add enforce_agent_no_network and sandbox_model_server to these servers. When enabled, the agent's sandbox gets a deny-by-default policy that allows only the model server's host. It fails closed for a provider without network-policy support or a model server that advertises a loopback host. Evaluation sandboxes keep their network. The setting is off by default. The servers with episode sessions treat the sandbox created for a session as the agent's; scale_swe and swe_next mark it with for_agent. The shared policy builder lives in resources_servers/swebench. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
|
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. |
Move enforce_agent_no_network and sandbox_model_server into one config mixin, AgentNetworkConfig, in resources_servers/swebench/agent_network.py, and follow the rules LentSandboxes applies to a lent sandbox: - the config refuses the flag without sandbox_model_server, or alongside a network_policy in sandbox_config.provider_options; - startup refuses a provider that cannot enforce network policies; - a model server the sandbox cannot reach refuses the seed with ResourcesSeedRejectedError (HTTP 422), so it fails once instead of being retried. Add swe_internal_v1, which seeds the agent's sandbox the same way as swe_rebench. Each server now switches its config base class and calls the mixin at startup and when it builds the sandbox spec. List both keys in each server's YAML config. Tests now build the real servers: seeding gives the agent's sandbox the block, the evaluation sandbox keeps its network, and the config, startup and seed refusals hold. The scale_swe session test records which sandboxes were created for the agent. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
RISK: Complete a representative model-driven rollout
The PR explicitly reports no full OpenCode rollout. The real-sandbox egress probes and two successful golden-patch grades are useful evidence, but they do not exercise runtime setup, inference through the advertised Gym model endpoint, and verification together. AGENTS.md requires representative real smoke rollouts for behavior-changing environment work.
Could you run one supported pairing end to end on the latest commit, using a sandbox-reachable Gym model server and an offline-ready OpenCode runtime? Keep the agent's network_access at inherit; do not broaden the allowlist to make installation succeed. Record the command, task, model, rollout artifact and inspected verifier outcome. Acceptance should show that the agent reaches the Gym model endpoint, external hostname and literal-IP requests are blocked, and grading completes in a separate sandbox with its original network settings. Retain the reported golden-patch checks and confirm that the same pairing still runs with enforcement disabled. No reward-distribution comparison is requested because this PR does not change the verifier's scoring logic.
NOTE: Document the new SWE configuration in the shipped guide
Suggestion: add a short section to the existing OpenSandbox egress guide. The new YAML entries expose the switch, but neither those entries nor the existing guide explains how to configure these seven servers. The operational requirements currently live in the PR description and the config mixin's docstring.
Include one complete resources-server overlay with a structured sandbox_model_server reference matching the agent's model, the offline-runtime requirement, and the dns+nft deployment prerequisite. Keep the distinctions explicit: enforcement defaults off, only agent sandboxes receive the injected policy, and the allowed host is reachable on every port. Acceptance is a documented example that resolves against a shipped pairing and describes both restricted agent execution and unrestricted grading without suggesting that DNS-only filtering provides full isolation.
I completed static inspection of all 23 changed files and their directly affected seed, policy and verification paths. I did not execute tests or rollouts. The inline RISK identifies a source-evidenced import-contract regression.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 0f84c2c |
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed 0f84c2c: the seven SWE servers apply the opt-in policy to agent sandboxes while leaving verification sandboxes unrestricted; invalid provider/model configurations fail closed, and the public-import regression is fixed. No additional blocking implementation issue found in this static review.
Validation limits: I did not run tests or model rollouts for this review, and this pass was not independently checked. CI is still running. The author's real-sandbox egress probes and golden-patch grading are useful evidence, but the full model-driven OpenCode smoke remains outstanding as documented in the PR. This approval does not certify that validation as complete.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43960383607 |
What changed
Adds the agent egress block that
deepswealready has, under the same config keys, to seven SWE resources servers:swe_rebench,swe_internal_v1,swemer_v1,swemer_v2,swemer_oml,scale_sweandswe_next.enforce_agent_no_network(defaultfalse): when on, the sandbox the server creates for the agent gets a deny-by-default network policy.sandbox_model_server: the model server whose host the policy allows, on every port, so the agent can still reach the model.The fields and rules live in one config mixin,
AgentNetworkConfig, inresources_servers/swebench/agent_network.py. Each server switches its config base class and calls the mixin at startup and when it builds the sandbox spec. The mixin follows the rules coreLentSandboxesapplies to a lent sandbox:sandbox_model_server, or alongside anetwork_policyinsandbox_config.provider_options.ResourcesSeedRejectedError(HTTP 422), so it fails once instead of being retried.Only the agent's sandbox is restricted. Evaluation sandboxes keep their network, because grading installs test dependencies.
swe_rebench,swe_internal_v1and theswemerservers already create the agent's sandbox for a session and evaluation sandboxes for a verifier session, so the block applies to the session's sandbox.scale_sweandswe_nexthave no such marker, so their_create_sandboxtakes a keyword-onlyfor_agentflag that seeding sets.Not covered:
swemer_ultra,swe_gym,r2e_gymanddenovo_swealso seed an agent sandbox, and this change does not touch them.Why
With open egress, RL agents learn to fetch the task's upstream fix: newer package releases, or the fixed source from GitHub, through any language runtime. A command deny-list cannot stop that. These servers create the agent's sandbox in
seed_sessionand lend it to the agent, so the agent's ownnetwork_accesssetting cannot put a policy on it.No issue is linked. The field names match
deepswe's, so recipes that already set them fordeepswework unchanged here.Turning it on
The setting is off by default, so existing configs behave as before. Both keys are listed in each server's YAML config. A recipe that turns it on needs:
sandbox_model_servernaming the same server as the agent'smodel_server, advertising a host the sandbox can reach (use_absolute_ip=true);preinstalled_opencodeor theremote_opencode_*settings foropencode_sandboxed_agent, the preinstalled binary and its SHA-256 foropencode_agent. Without ripgrep in the image, OpenCode's grep and glob tools stop working, but the rollout still runs;network_accessleft atinherit. Both OpenCode agents refuse any other value on a lent sandbox.Tests
Each of the seven servers has a test module that builds the real server with a recording sandbox and checks that:
network_policy;The
scale_swesession test stubs record which sandboxes were created for the agent, and the full seed-and-verify flow checks that only the task sandbox was. The new tests fail on the base branch. They also fail when seeding stops passingfor_agent, when the startup check is removed, and when the seed refusal is not turned into a 422.Commands run:
Rollout evidence
Ran locally on a workstation at
ee136f4045, driving sandboxes on a remote OpenSandbox deployment. No Slurm job.Not run: a full OpenCode rollout. OpenCode in the sandbox calls the Gym model server's own address, and a remote sandbox cannot reach a server on the workstation. That is true with the flag off as well, so this setup cannot finish an OpenCode rollout either way. The checks below exercise each part of the change on real sandboxes instead.
Waiting: the OpenCode rollout with the flag on, on a Slurm CPU node. Gym runs on the cluster node, which the sandbox can reach, but our OpenSandbox deployment has no OpenCode mount, so with egress blocked the sandbox cannot install OpenCode. That run waits on #6232, which uploads a pinned local OpenCode binary.
Egress from the agent's sandbox. A small driver built each server's real config and server object, and created the agent's sandbox and an evaluation sandbox through the server's own
_create_sandbox. The policy model server was set to advertiseinference-api.nvidia.com. It then rancurlinside each sandbox:pypi.orggithub.comswe_rebench, onswe_rebench, onswemer_v1, onswemer_v1, onscale_swe, onscale_swe, onswe_rebench, offswe_rebench, offThe policy on each flag-on agent sandbox was
{"defaultAction": "deny", "egress": [{"action": "allow", "target": "inference-api.nvidia.com"}]}. The 401 is the inference API answering an unauthenticated request, so the allowed host is reachable through the policy. The probe sent no key into the sandbox.Grading with the flag on.
gym env startran theswe_rebenchservers with the flag on andsandbox_model_serverset to anopenai_modelpolicy server.apply_golden_patch.pythen graded two example rows,intel__rohd-458andsyuilo__aiscript-257. Both scored reward 1.0, with the patch applied and evaluation completed, so the evaluation sandbox still installs and grades.Startup refusal.
gym env startforswe_rebenchwith the flag on and nosandbox_model_serverstops at startup with "enforce_agent_no_network needs sandbox_model_server, the model server the agent calls".