Repository navigation
Conversation
With open egress, RL agents learned to fetch the task's upstream fix (newer package releases, the fixed source from GitHub, through any runtime). The swe_rebench and swe_internal_v1 servers create the agent's sandbox in seed_session and hand it to the agent, so the agent's own network_access cannot apply a policy there and refuses to run. Add enforce_agent_no_network and sandbox_model_server to both servers. When enabled, the agent's sandbox gets a deny-by-default policy that allows only the model server's host; a network_policy already in sandbox_config.provider_options is kept and extended with that host, as in deepswe. Evaluation sandboxes never get a network_policy, so they keep their network. A config that cannot work (no sandbox_model_server, or a provider without network-policy support) fails at server startup; an unreachable model server host fails when the sandbox is created. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Sandboxes from swe_rebench and swe_internal_v1 only get the toolchain setup the servers hardcode: swe_rebench writes the Maven mirror into the evaluation sandbox, and swe_internal_v1 writes none. An image that needs more (the mirror in the agent's sandbox, a Chrome wrapper so Karma can start Chrome as root with a small /dev/shm) had no way to get it. Add two sandbox_config keys to both servers, applied to the agent's and the evaluation sandbox: - files: sandbox path -> local source file (relative to the Gym root), uploaded at create time. The evaluation's own files win on a shared path. A missing source fails at server startup. - setup_command: run once after the sandbox starts; a non-zero exit stops the sandbox and fails the request. With sandbox_config.env these cover the setup a recipe needs. Ship a Chrome wrapper under swebench/toolchain/ and document an example in the swe_rebench README. Defaults are unchanged. Based on Jiaqi Zeng's container setup change (e086567), made configurable instead of hardcoded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
3a38093 to
75a9889
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for this. Server-side enforcement fills a real gap: a harness's network_access never applies to a task sandbox borrowed from the resources server, so swe_rebench and swe_internal_v1 are the only place to restrict the agent's egress. Using SandboxSpec.files and start_with_setup() for the toolchain setup follows the sandbox rules in AGENTS.md, and a failed setup is stopped and retried as an inconclusive evaluation, as expected.
The points to address are inline. The main one is that a configured network_policy can keep the agent's egress open while the flag is on.
Not covered: we did not run a real OpenSandbox sandbox or a model. The two servers' unit tests pass at this head and when merged onto current main.
For a follow-up rather than this PR: deepswe and swebench_pro each have their own copy of this agent-egress logic, and they disagree on how to combine it with a configured policy. This new helper could become the shared one.
| policy = restricted_network_policy(provider_name, [sandbox_server_url(model_server.name, require_reachable=True)]) | ||
| if configured is None: | ||
| return policy | ||
| merged = deepcopy(dict(configured)) |
There was a problem hiding this comment.
resources_servers/swebench/agent_network.py:52
When provider_options.network_policy is also configured, this copies it and only appends the model allow rule, so the configured defaultAction survives. A config with defaultAction: allow (or an allow rule for a code host) leaves the agent's egress open while enforce_agent_no_network: true says it is closed, and nothing reports it. Main's agent-side helper refuses this combination instead (sandbox_network.py:45: "Set network_access or sandbox_config.provider_options.network_policy, not both"). Could you either refuse a configured policy at startup when the flag is on, or force deny and add a test with a configured allow policy? For example:
| merged = deepcopy(dict(configured)) | |
| merged = deepcopy(dict(configured)) | |
| # The flag promises deny-by-default, whatever the configured policy said. | |
| merged["defaultAction"] = "deny" |
There was a problem hiding this comment.
Fixed in 7d432ba. With enforce_agent_no_network on, both servers now refuse a configured network_policy at startup, as the agent-side helper does; forcing deny alone would keep the configured allow rules. Added startup tests for both servers.
| from typing import Any, Mapping, cast | ||
|
|
||
| from nemo_gym.config import ModelServerRef | ||
| from nemo_gym.sandbox.agent_tools import restricted_network_policy, sandbox_server_url |
There was a problem hiding this comment.
resources_servers/swebench/agent_network.py:25
nemo_gym.sandbox.agent_tools is a moved path (_moved_paths.py:116): it warns now and is removed in 0.10.0. AGENTS.md asks code outside nemo_gym/ to import from the public API, as swebench_pro does (app.py:38). The tests also patch the old path (swe_rebench/tests/test_app.py:610, swe_internal_v1/tests/test_app.py:375); they should patch nemo_gym.agents.agent_tools.get_server_url.
| from nemo_gym.sandbox.agent_tools import restricted_network_policy, sandbox_server_url | |
| from nemo_gym.agents import restricted_network_policy, sandbox_server_url |
There was a problem hiding this comment.
Fixed in 7d432ba. Imports now come from nemo_gym.agents, and both servers' tests patch nemo_gym.agents.agent_tools.get_server_url.
| --config responses_api_models/vllm_model/configs/vllm_model.yaml | ||
| ``` | ||
|
|
||
| ## Sandbox toolchain setup |
There was a problem hiding this comment.
resources_servers/swe_rebench/README.md:92
Neither README documents enforce_agent_no_network / sandbox_model_server, and a few things about it are easy to trip on:
- The shipped
swe_rebench_opencode.yamlpairing runs OpenCode inside the borrowed task sandbox and, by default, downloads it fromopencode.ai(opencode_sandboxed_agent/app.py:1268). With the flag on, that download is denied and every rollout fails at seed, unlesspreinstalled_opencodeorremote_opencode_*is set. MCP tool hosts are blocked too. - It needs the OpenSandbox provider and a model host that sandboxes can reach (
use_absolute_ip). A loopback host passes the startup check and then fails eachseed_session. setup_commandalso runs in the agent sandbox after egress is restricted, so a step that downloads anything works in evaluation but fails at seed. The Maven/Gradle mirror in the example below is unreachable for the agent too.
Could you add a short section covering these (same in swe_internal_v1/README.md)?
There was a problem hiding this comment.
Fixed in 7d432ba. Added an "Agent network restrictions" section to both READMEs covering these points.
| ), | ||
| ) | ||
| body = app.SWERebenchInstanceRequest(instance_id="o__r-1", repo="o/r", base_commit="abc", image_name="img") | ||
| return await app.SWERebenchResourcesServer._create_sandbox(server, body, for_agent=for_agent) |
There was a problem hiding this comment.
resources_servers/swe_rebench/tests/test_app.py:630
These tests choose for_agent themselves, so the wiring the feature depends on is untested: dropping for_agent=True from seed_session (app.py:302) or passing it from verify (app.py:371) still passes the whole suite (we checked by mutating both). Could you add, for both servers:
- a test that runs the real
seed_sessionandverifywith onlyAsyncSandboxfaked, and asserts that the agent spec hasdefaultAction: denyand the evaluation spec has nonetwork_policy; - a test that builds the server with
enforce_agent_no_network: trueand nosandbox_model_server, or with a missingfilessource, and expects the startup error; - a failing
setup_command:verifyreturnsevaluation_completed=Falseafter retries and stops each sandbox, andseed_sessionraises without keeping the sandbox.
test_agent_sandbox_gets_the_files_and_setup (:730) also never passes for_agent=True, and only asserts setup is not None.
There was a problem hiding this comment.
Fixed in 7d432ba. Added tests for both servers that go through the real seed_session and verify with only the provider faked: agent and evaluation network policies, startup errors, and setup_command failures (verify retries and stops each sandbox, seed keeps none). Also made setup treat a non-None error_type as a failure.
| @@ -0,0 +1,57 @@ | |||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |||
There was a problem hiding this comment.
resources_servers/swebench/agent_network.py:1
A few PR-description asks:
- Rollouts. This changes agent behavior, and AGENTS.md asks for real smoke rollouts on such changes. Could you share one OpenSandbox run per server with
enforce_agent_no_network: truethat shows the model calls succeed and an outbound fetch (for example to github.com) is denied, plus one row graded with the toolchainfiles/setup_commandon a real image (for example the Chrome wrapper with Karma)? - Issue. Please link an issue, or say why none is needed.
- Pre-commit. The validation lists
pre-commit run --from-ref origin/main --to-ref HEAD, but the checklist ticks--all-files. Which one ran?
There was a problem hiding this comment.
Updated the description at 7d432ba: Rollouts now has the smoke run for both servers, it states why no issue is needed, and pre-commit run --all-files passes.
…rk loans swe_internal_v1 goes back to its mapping sandbox_config: PRs #5656 and #6173 read new keys from it with .get(), so it moves to the stage after they merge. LentSandboxes now refuses network_access no_network, since the harness in a lent sandbox calls the model server, and SandboxNetwork's validator returns Self. Signed-off-by: Ananth Subramaniam <[email protected]>
…ess-setup Signed-off-by: bg51717 <[email protected]> # Conflicts: # resources_servers/swe_internal_v1/app.py # resources_servers/swe_rebench/app.py
…no_network With the flag on, a configured provider_options.network_policy kept its allow rules for the agent, so both servers now refuse the combination at startup, as the agent-side helper does. Import the network helpers from nemo_gym.agents, treat a setup_command error_type as a failure, and document the agent network restrictions. Test the wiring through seed_session and verify with only the sandbox provider faked: the agent and evaluation network policies, files and setup_command, setup failures and their cleanup, and startup errors. Signed-off-by: bg51717 <[email protected]>
What does this PR do?
Two opt-in sandbox options for the
swe_rebenchandswe_internal_v1servers, both off by default:enforce_agent_no_networkwithsandbox_model_server: the agent's sandbox gets a deny-by-default network policy that allows only the model server's host. With open egress, RL agents learned to fetch the task's upstream fix. Evaluation sandboxes keep their network. A config that cannot work fails at server startup.sandbox_config.filesandsandbox_config.setup_command: files uploaded and a command run when the agent's and the evaluation sandbox start, for images that need extra toolchain setup (for example a Maven mirror, or the shipped Chrome wrapper underswebench/toolchain/so Karma can start Chrome as root).The setup options are based on Jiaqi Zeng's container setup change (e08656718), made configurable instead of hardcoded.
No separate issue: this PR documents the agent-egress gap and the sandbox setup it addresses.
Proposed labels:
feature,area:environment.Validation
At 7d432ba:
gym env test +entrypoint=resources_servers/swe_rebench +should_validate_data=true: 97 passedgym env test +entrypoint=resources_servers/swe_internal_v1 +should_validate_data=true: 69 passedgym env test +entrypoint=resources_servers/swebench +should_validate_data=true: 178 passedpre-commit run --all-files: passedRollouts
Smoke run at 7d432ba.
Setup:
vllm servewith a Nemotron Nano checkpoint, thengym env startandgym eval run --no-serve, as intests/e2e/gpu_e2e_test.sh.swe_rebench_opencode.yamlandswe_internal_v1_opencode.yaml(opencode_sandboxed_agent),opensandbox.yaml,use_absolute_ip: true,sandbox_model_server: policy_model, and OpenCode fromremote_opencode_*.filesandsetup_command.seed_session, as the agent does, and runs curl, a DNS lookup and a TCP connect to github.com's IP in it. It does not go through the model, since OpenCode's default permissions refuse fetches to github.com.Results:
chartjs__chartjs-plugin-zoom-488resolves on its real image with the wrapper. Its install already adds--no-sandbox, so it also resolves without the wrapper.Compatibility and benchmark impact
None by default. With
enforce_agent_no_network, agents can no longer reach the internet, which can change scores of agents that relied on it.Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).