Repository navigation
fix(agents): follow-ups to the session-harness egress controls - #5718
gwarmstrong wants to merge 9 commits into
Conversation
assert_model_url_reachable_from_sandbox raises AgentSeedRejectedError, still a ValueError, for a loopback model URL on a remote sandbox provider. The same configuration fails every attempt, so every seed path that checks it (Hermes, mini-SWE, BrowseComp) now refuses it once with HTTP 422 instead of a retried 500. Hermes's local conversion is gone; mini-SWE and BrowseComp re-raise the refusal unchanged and keep converting other ValueErrors. Suggested in the review of NVIDIA-NeMo#5558. Signed-off-by: gwarmstrong <[email protected]>
restrict_sandbox_network logs one INFO line with the provider, the network_access mode and the hosts the policy allows whenever it restricts a spec, so an operator can tell a restricted run from an open one; inherit logs nothing. The mode is not added to the sandbox observation: only two of the six session harnesses emit one, so that needs a schema change and per-adapter plumbing and stays a follow-up. Suggested in the review of NVIDIA-NeMo#5554. Signed-off-by: gwarmstrong <[email protected]>
The six session-harness configs ignored keys they do not declare, so a misspelled network_access silently left the sandbox on the provider's open network. They now extend StrictResponsesAPIAgentConfig, which forbids undeclared keys and declares the three that other components read from an agent's block: datasets, description and tool_servers. pi_sandboxed_agent inherits it through PiAgentConfig. Every shipped config that uses these agents still validates (31 composed agent blocks checked). The OpenCode math and reasoning-gym presets set setup_timeout, which OpenCode no longer has; it is removed. Each adapter's profile test composes its profile onto HLE with a misspelled network_access and checks it is refused. Suggested in the review of NVIDIA-NeMo#5554. Signed-off-by: gwarmstrong <[email protected]>
opencode_math and opencode_reasoning_gym run OpenCode on the Gym host through /run, where network_access does not apply, and allowed its webfetch tool, so the harness could look up answers on math and reasoning tasks. Both now set permission.webfetch: deny, and a test checks the resolved presets. Raised in the review of NVIDIA-NeMo#5555. Signed-off-by: gwarmstrong <[email protected]>
The deprecation notice and the startup warning now say that pi_agent supports the same network_access values and that its benchmark profile defaults to model_only, as this agent's does, so moving off the deprecated agent no longer opens the sandbox's network. The HLE search presets still stay here until the environment server can grant tool servers. Tracked in NVIDIA-NeMo#5552. Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test ad7e5ca |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE — two RISK items remain: the restriction diagnostic isn't enabled by the normal non-verbose startup path, and the changed OpenCode presets lack the required real smoke-rollout evidence.
I inspected all 26 changed files and traced their affected configuration, session-error, runtime, and test contracts. The terminal-422 propagation and strict-config inheritance look consistent with those contracts. This was a static review; I didn't execute tests or rollouts.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| except ValueError as error: | ||
| raise AgentSeedRejectedError(str(error)) from error | ||
| # An operator can tell a restricted run from an open one only from this line. | ||
| LOG.info( |
There was a problem hiding this comment.
RISK — Make the restriction record visible without verbose mode
For an agent process launched with verbose: false and telemetry disabled, this INFO record has no INFO-capable logging setup in Gym's startup path. The supervisor launches separate interpreters with an injected configuration; loading that configuration configures logging only when verbose is true, while disabled telemetry returns without installing its logging bridge. This logger consequently inherits the default WARNING threshold, so an ordinary restricted session loses the diagnostic intended to distinguish it from an open one. Enforcement itself is unaffected.
Could you make this diagnostic survive normal agent startup, either through a narrowly scoped INFO logging configuration or a retained log level? The implementation choice needs care, so I haven't proposed a blanket logging patch: preserve existing handler ownership and avoid enabling every dependency's INFO output or duplicating this record.
Acceptance checks, proposed: capture a fresh agent process's output with an injected configuration, verbose off, and telemetry off. A successful model_only restriction must produce one record naming the provider, mode, and normalized model host; model_and_tools must also name the distinct tool hosts without credentials, paths, or queries. Preserve inherit returning the original spec without a record, and rejected policies returning 422 without a successful-restriction record. The current test explicitly enables INFO, so it doesn't establish startup visibility. These checks weren't executed in this review.
There was a problem hiding this comment.
Confirmed: in a fresh agent process with the injected config, verbose off and telemetry off, the INFO record reached no handler and was dropped. 43e130a logs it at INFO where INFO reaches a handler and at WARNING otherwise, so the fallback stderr handler prints it; no handler is added and nothing is duplicated. A new subprocess test runs that startup path for model_only and model_and_tools, verbose off and on, and checks for exactly one line naming the provider, mode and hosts, with no credentials, paths, query strings or ports. It fails without the fix; inherit and rejected policies still log nothing.
| edit: allow | ||
| webfetch: allow | ||
| # The harness runs on the Gym host with its network, so keep it from looking answers up. | ||
| webfetch: deny |
There was a problem hiding this comment.
RISK — Provide real smoke evidence for the preset permission change
Could you add representative model-backed smoke rollouts for this preset and the Reasoning Gym preset? Changing webfetch from allow to deny changes the tools available during an episode; it isn't only a startup-validation or documentation change. The PR's rollout N/A therefore doesn't satisfy the required smoke-rollout check for behavior-changing environment or agent work.
The added test establishes the resolved YAML value, but it doesn't establish that the pinned CLI enforces it while the host /run path still completes and reaches verification. This is a validation gap, not a demonstrated runtime failure.
Correction and acceptance: run each changed preset with a real model on representative rows and record the command, model, rollout artifacts, and inspected agent/verifier outcomes in the PR. Include a controlled attempt to use webfetch and show that it is refused without fetching the target. Preserve the intended local calculation tools: a Bash calculation must still work, ordinary final answers must reach each preset's verifier, and verification must complete rather than hang on a permission prompt. Keep the permission denial and existing preset assertions. No code replacement is indicated unless those checks expose a failure; I didn't execute these proposed checks.
There was a problem hiding this comment.
Smoke runs at 4edf581 against inference-api.nvidia.com, each preset with its own model: two example rows plus a row asking for a webfetch of a local canary URL. Both completed and graded every row with no permission hang; reasoning_gym scored 1.0 on both real rows, and math scored 0 on both, one a wrong answer and one with no answer found, all graded. OpenCode 1.17.11 with webfetch: deny does not offer the tool at all; in a direct run with bash denied, the canary got no request, and with allow it was fetched. But on the math preset the model fetched the canary with curl through bash, since host /run keeps the host network, so 4edf581 changes the comments to say this setting removes the webfetch tool, not network access. The PR description and its Rollouts section now say the same.
Signed-off-by: gwarmstrong <[email protected]>
…se logging A Gym server process configures logging only with verbose, so the INFO record that tells a restricted sandbox from an open one reached no handler and was dropped. Log it at INFO where INFO reaches a handler, and at WARNING otherwise, so Python's last-resort handler prints it. No handler is added and the record is not duplicated. Signed-off-by: gwarmstrong <[email protected]>
…not network access A smoke run showed OpenCode 1.17.11 leaves webfetch out of the tools it offers when the permission is deny, but a model asked to fetch a URL used curl through bash, which runs with the Gym host's network. State what the setting does. Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test 4edf581 |
… allowed Signed-off-by: gwarmstrong <[email protected]>
|
/ok to test f1d440f |
What does this PR do?
Collects the follow-ups that reviewers raised on the session-harness egress stack (#5554-#5559) and that #5552 tracks. Each item is its own commit.
assert_model_url_reachable_from_sandboxraisesAgentSeedRejectedError, which is still aValueError, for a loopback model URL on a remote sandbox provider. The same configuration fails every attempt, so every seed path that checks it (Hermes, mini-SWE, BrowseComp) refuses it once with HTTP 422 instead of a retried 500. Hermes's local conversion is gone; mini-SWE and BrowseComp re-raise the refusal unchanged and keep converting their otherValueErrors.restrict_sandbox_networklogs one line with the provider, thenetwork_accessmode and the allowed hosts whenever it restricts a spec;inheritlogs nothing. The line is INFO where INFO reaches a handler and WARNING otherwise, so an agent started without verbose logging or telemetry still prints it. This is the only record of whether a run's sandbox was restricted. The mode is not added to the sandbox observation: only Claude Code and OpenCode emit one among the six session harnesses, so that needs a schema change and per-adapter plumbing (left in Session harnesses: close the gaps with the deprecated sandboxed agents for evaluation frameworks #5552).network_accesssilently left the sandbox open. The six configs (andpi_sandboxed_agentthroughPiAgentConfig) now extendStrictResponsesAPIAgentConfig, which forbids undeclared keys and declares the three that other components read from an agent's block:datasets,descriptionandtool_servers. Every shipped config that uses these agents still validates (31 composed agent blocks). The OpenCode math and reasoning-gym presets setsetup_timeout, which OpenCode no longer has, so it is removed.environments/opencode_mathandenvironments/opencode_reasoning_gymrun OpenCode on the Gym host through/run, wherenetwork_accessdoesn't apply, and allowedwebfetch. Both now setpermission.webfetch: deny, which removes OpenCode's webfetch tool. It does not cut network access: bash on the host still has the network, and in the smoke run below the model fetched a URL withcurl. The preset comments say so.pi_sandboxed_agent's deprecation notice (Session harnesses: close the gaps with the deprecated sandboxed agents for evaluation frameworks #5552). The README and startup warning now say thatpi_agentsupports the samenetwork_accessvalues and that its benchmark profile defaults tomodel_only, so moving off the deprecated agent no longer opens the sandbox's network.Why. These came out of the review of the egress stack. Items 1-3 close gaps in how the restriction fails, is recorded and is configured; items 4-5 close the remaining routes and docs. Part of #5552.
Still open in #5552: one restricted mode for agent sessions, or dropping optional grants that
model_onlyblocks (OpenClaw's probe and Hermes's import wait); lettingSandboxAccesscarry the owner's egress posture; moving the helper onto #5363'sSandboxSpec.egress_rules; the other agents withoutnetwork_access; the network mode on the sandbox observation; and live runs of the paths not yet run behind the policy.Validation
mainmerged 2026-11-12): coretests/unit_tests/agents594 passed, 2 skipped;tests/unit_tests/environmentand the public-API facades 1610 passed; OpenCode 945 passed, 1 skipped; viang_test: Pi 387, Claude Code 206, Codex 549, Hermes 372, OpenClaw 524,pi_sandboxed_agent62, BrowseComp 148, mini-SWE 200. The new restriction-record test runs the agent startup path in a subprocess with verbose off and on, and fails without the fix.pre-commitclean.webfetch: deny, and the deprecation warning's wording.tests/unit_tests/agents,environment,config, the public-API facades and docs links): 2384 passed, 4 failed. The four are environmental: threetest_outcome_policy.pycases needcloudpickle, which the local venv lacks, andtest_every_repo_benchmark_appears_in_listingfails because this host's hostname resolves to 127.0.1.1.gym env testin each adapter's own environment: Pi 359 passed (plus the knowntest_gym_mcp.mjsfailure, which needs Node 22), OpenCode 825, Codex 529, OpenClaw 515, Hermes 368, Claude Code 197,pi_sandboxed_agent51, mini-SWE 198, BrowseComp 147. Each harness'stest_benchmark_profile.pycomposes its profile onto HLE with a misspellednetwork_accessunder the profile's own instance name and checks it is refused (under the composed name an unknown key already fails at resolve).pre-commit runon the changed files: clean.Rollouts
Smoke runs of the two OpenCode presets at 4edf581 (item 4), each with its own model on inference-api.nvidia.com (
gym env start --config environments/<preset>/config.yaml --model-type openai_model, thengym eval run --no-serve): two example rows plus one row asking the model to webfetch a local canary URL that logs every request.opencode_math(qwen3-5-397b-a17b): all three rows completed and were graded with no permission hang. The example rows scored 0 (one wrong answer, one with no answer found). On the canary row the model fetched the URL withcurlthrough bash, then answered (reward 1).opencode_reasoning_gym(qwen3-next-80b-a3b-instruct): the example rows scored 1.0 and 1.0; on the canary row the model wrote a webfetch call as text and the canary got no request.webfetch: denythe model's tool list has no webfetch and the canary got no request; withallowthe model called webfetch and the canary logged the fetch.Items 1-3 and 5 don't change how an episode runs: a seed refusal's status code, a log line, rejecting configs that were already wrong, and docs. The egress behavior these follow up on was validated in #5554-#5559.
Compatibility and benchmark impact
pi_sandboxed_agent, naming the key. No shipped Gym config is affected after removing OpenCode's stalesetup_timeout. An external config that sets a key its agent doesn't declare will need it removed. OpenCode'smax_steps, which an evaluation overlay sets, is declared by the open feat(opencode): cap the build agent's steps with max_steps #5716; whichever of feat(opencode): cap the build agent's steps with max_steps #5716 and this PR merges second needs only a rebase.Checklist
pi_sandboxed_agent's README and the strict config's docstring.pre-commit run --all-files).git commit -s).