Skip to content

fix(agents): follow-ups to the session-harness egress controls - #5718

Open
gwarmstrong wants to merge 9 commits into
NVIDIA-NeMo:mainfrom
gwarmstrong:georgea/egress-followups
Open

gwarmstrong wants to merge 9 commits into
NVIDIA-NeMo:mainfrom
gwarmstrong:georgea/egress-followups

Conversation

@gwarmstrong

@gwarmstrong gwarmstrong commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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.

  1. A sandbox-unreachable model URL is a final 422 (from the feat(hermes): restrict the egress of agent-created sandboxes #5558 review). assert_model_url_reachable_from_sandbox raises AgentSeedRejectedError, which is 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) 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 other ValueErrors.
  2. Each egress restriction is logged (from the feat(pi): restrict the egress of agent-created sandboxes #5554 review). restrict_sandbox_network logs one line with the provider, the network_access mode and the allowed hosts whenever it restricts a spec; inherit logs 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).
  3. The session-harness configs reject undeclared keys (from the feat(pi): restrict the egress of agent-created sandboxes #5554 review). They ignored keys they don't declare, so a misspelled network_access silently left the sandbox open. The six configs (and pi_sandboxed_agent through PiAgentConfig) 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. Every shipped config that uses these agents still validates (31 composed agent blocks). The OpenCode math and reasoning-gym presets set setup_timeout, which OpenCode no longer has, so it is removed.
  4. OpenCode's host-run presets drop the webfetch tool (from the feat(opencode): restrict the egress of agent-created sandboxes #5555 review). environments/opencode_math and environments/opencode_reasoning_gym run OpenCode on the Gym host through /run, where network_access doesn't apply, and allowed webfetch. Both now set permission.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 with curl. The preset comments say so.
  5. 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 that pi_agent supports the same network_access values and that its benchmark profile defaults to model_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_only blocks (OpenClaw's probe and Hermes's import wait); letting SandboxAccess carry the owner's egress posture; moving the helper onto #5363's SandboxSpec.egress_rules; the other agents without network_access; the network mode on the sandbox observation; and live runs of the paths not yet run behind the policy.

Validation

  • At 4edf581 (main merged 2026-11-12): core tests/unit_tests/agents 594 passed, 2 skipped; tests/unit_tests/environment and the public-API facades 1610 passed; OpenCode 945 passed, 1 skipped; via ng_test: Pi 387, Claude Code 206, Codex 549, Hermes 372, OpenClaw 524, pi_sandboxed_agent 62, 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-commit clean.
  • Each new test fails with its change reverted: the loopback refusal type, the restriction log line, the strict base config and each adapter's use of it, the presets' webfetch: deny, and the deprecation warning's wording.
  • Core tests (tests/unit_tests/agents, environment, config, the public-API facades and docs links): 2384 passed, 4 failed. The four are environmental: three test_outcome_policy.py cases need cloudpickle, which the local venv lacks, and test_every_repo_benchmark_appears_in_listing fails because this host's hostname resolves to 127.0.1.1.
  • Adapter suites via gym env test in each adapter's own environment: Pi 359 passed (plus the known test_gym_mcp.mjs failure, which needs Node 22), OpenCode 825, Codex 529, OpenClaw 515, Hermes 368, Claude Code 197, pi_sandboxed_agent 51, mini-SWE 198, BrowseComp 147. Each harness's test_benchmark_profile.py composes its profile onto HLE with a misspelled network_access under the profile's own instance name and checks it is refused (under the composed name an unknown key already fails at resolve).
  • Strict-config sweep: every shipped config that instantiates one of these agents and resolves offline was composed, and each agent block validated against its strict config (31 blocks, no undeclared keys).
  • pre-commit run on 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, then gym 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 with curl through 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.
  • OpenCode 1.17.11 run directly with bash denied: with webfetch: deny the model's tool list has no webfetch and the canary got no request; with allow the 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

  • Configs with undeclared keys now fail at startup for the six session harnesses and pi_sandboxed_agent, naming the key. No shipped Gym config is affected after removing OpenCode's stale setup_timeout. An external config that sets a key its agent doesn't declare will need it removed. OpenCode's max_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.
  • A loopback model URL on a remote sandbox is now a 422 instead of a retried 500 for Hermes, mini-SWE and BrowseComp, so the episode fails once.
  • The OpenCode host-run math and reasoning-gym presets no longer offer OpenCode's webfetch tool, so scores from runs that used it are not comparable. Bash still has the host network; these presets are not network-isolated.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes.
  • Documentation added or updated, or N/A with justification. pi_sandboxed_agent's README and the strict config's docstring.
  • Pre-commit checks pass locally (pre-commit run --all-files).
  • New source files include the required Apache-2.0 SPDX header. N/A: no new source files.
  • All commits have DCO sign-off (git commit -s).

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]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@gwarmstrong

Copy link
Copy Markdown
Contributor Author

/ok to test ad7e5ca

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 6, 2026 22:05
@kajalj22
kajalj22 removed the request for review from a team November 6, 2026 22:41
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior needs-review PR is ready for code review and waiting on a reviewer labels Nov 7, 2026
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 9, 2026
…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]>
@gwarmstrong

Copy link
Copy Markdown
Contributor Author

/ok to test 4edf581

@gwarmstrong

Copy link
Copy Markdown
Contributor Author

/ok to test f1d440f

This branch was previously deployed

1 inactive (outdated) deployment
public — ad7e5ca7 Deployed Nov 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #10569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants