Skip to content

feat(hle,apex_shortlist): run the Pi presets through pi_agent sessions - #5826

Merged
weijiac0619 merged 20 commits into
mainfrom
yuya/hle-apex-pi-sessions
Nov 11, 2026
Merged

weijiac0619 merged 20 commits into
mainfrom
yuya/hle-apex-pi-sessions

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

#5825 is merged, and main is merged in (5a8650e), so the diff against main is now only the Pi change. Commits of this PR: 5ce8169, 96b0c83, the review-fix commit e65e46a, dfc4a73, 7908d10 and 3c34792; the merge commits between them only bring in main and #5825.

What changed and why

The HLE and APEX Shortlist Pi presets ran pi_sandboxed_agent, a deprecated agent, behind the legacy_agent relay. This PR moves them onto pi_agent sessions through each benchmark's single_agent_turn_legacy Environment Server, the same way #5825 does for OpenCode. The session presets take the plain names, and the relay presets are kept as *_legacy_agent.yaml with deprecation notes.

  • benchmarks/hle/pi.yaml, benchmarks/hle/pi_search.yaml, benchmarks/apex_shortlist/pi.yaml: pi_agent sessions. Each session creates its own sandbox from PI_SANDBOX_IMAGE; the search preset gets Tavily through the agent's tool_servers.
  • responses_api_agents/pi_agent/configs/profiles/offline_science.yaml: the shared settings. It composes profiles/benchmark.yaml and adds the offline science settings. They carry over pi_sandboxed_agent/configs/benchmark.yaml:
    • Pi 0.85.1 from the image's runtime (sandbox_runtime_dir: /opt; the image lays out /opt/node and /opt/pi);
    • model: benchmark-model;
    • a 262,144-token context with output_token_policy: remaining_context, and auto_compaction: false;
    • a 120 s Bash cap;
    • network_access: model_only;
    • the same system prompt, concurrency, timeouts and sandbox shape, except a 4.5-hour sandbox TTL: the run budget plus the seed's readiness wait (Round 3 below);
    • one worker instead of four. pi_agent's module exposes no app for uvicorn's extra workers, so four workers never start (Attribute "app" not found). Session routing would handle more workers; only the module app is missing. One worker admits at most 512 concurrent sessions, against 4 × 512 on the deprecated preset.
    • new, as in feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825: absolute_ip_server_types: [responses_api_models] (plus resources_servers in hle/pi_search.yaml), so only the model server leaves loopback; in hle/pi_search every Resources server does, the HLE judge included, because Tavily is one.
  • pi_agent fix: sessions now honor output_token_policy. With remaining_context they load remaining-context.mjs, which drops each request's output cap, instead of output-limit.mjs. Before, the setting applied only to local runs, so a session silently capped every call at max_output_tokens; with the preset's 262,144 that would ask for the whole window on every call. There is a new test in tests/test_sandbox.py, and the README says the policy applies to sessions.
  • Citations repointed: the routing test of the relay recipes and the example command in opencode_sandboxed_agent/README.md (hle/pi_search_legacy_agent).

Left for follow-up PRs

Each of these would change pi_agent for every preset, so none is made here.

  • Extra workers: pi_agent/app.py exposes no module-level app, so the profile runs one worker (512 sessions at most). Exporting it would allow the deprecated preset's 4 × 512.
  • execution_failure_reward_zero: the session path has no switch that scores a harness failure as 0.
  • Host artifact directory: there is none.
  • gym_mcp.mjs: its guard against output cut off at the cap sees no max_tokens under remaining_context. The relay behaves the same way.

Issue

No public issue. This retires the last pi_sandboxed_agent consumers outside HLE Diamond.

Compatibility and benchmark-result impact

--benchmark hle/pi, hle/pi_search and apex_shortlist/pi now run pi_agent. The _legacy_agent variants keep the relay. Agent instance names are unchanged; overrides of ...responses_api_agents.pi_sandboxed_agent.* belong with the _legacy_agent files.

What still differs from the deprecated preset (listed in the benchmark READMEs):

  • Failures. A run that stops at its output, context or time limit is graded on what it produced. A harness crash is retried and then reported as a failed rollout. The deprecated preset scored both as 0 (execution_failure_reward_zero).
  • Prompt. pi_agent's runtime guard adds a short sandbox-execution note to the system prompt.
  • Requests. pi_agent refuses request fields other than the input, instructions and model (for example temperature or reasoning) with 422.
  • Throughput. One agent worker: at most 512 concurrent sessions instead of 4 × 512.
  • Addresses. As in feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825, only the model server (and the Resources servers for search) bind the host address, so a client on another host can no longer reach the head, agent or Environment Server.
  • Artifacts. There is no host artifact directory.
  • Pi version (caveat, not a difference). Session Pi's outcome parsing was written against Pi 0.80.2. The preset pins 0.85.1 to match the image; the pairing runs below parse 0.85.1's output correctly.

Validation

  • pytest responses_api_agents/pi_agent/tests: 339 passed, 43 skipped. The 1 failure, test_opensandbox_sdk_is_available_in_agent_environment, needs the OpenSandbox SDK, which my local venv lacks.

  • pytest tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py tests/unit_tests/test_fern_docs_links.py: 165 passed.

  • gym env validate on all six presets: valid.

  • pre-commit run on the changed files: passed.

  • After the review fixes (e65e46a): gym env validate on hle/pi, hle/pi_search, apex_shortlist/pi, hle/pi_legacy_agent: valid; gym env resolve shows the scoped addresses; pytest responses_api_agents/pi_agent/tests/test_sandbox.py tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py tests/unit_tests/environment/test_benchmarks.py: 458 passed, 12 skipped, plus one timing failure (test_missing_events_use_shared_session_log_without_blocking_close[False]) on a loaded machine that passed three reruns; the fix commit touches no code.

  • Round 2 (feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 merged in, dfc4a73):

    • offline_science.yaml now composes profiles/benchmark.yaml. gym env resolve of hle/pi, hle/pi_search, apex_shortlist/pi, hle_diamond/pi and hle_diamond/pi_search before and after shows no difference, ignoring ports and the config_paths list.
    • pytest tests/unit_tests/environment/test_session_harness_benchmark_profiles.py tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py responses_api_agents/opencode_agent/tests responses_api_agents/pi_agent/tests: 1266 passed, 103 skipped. The one failure is the OpenSandbox SDK test described above.
    • CI on e65e46a failed in Sandbox tests (test_docker_compose.py::test_a_working_directory_the_image_lacks_is_created_before_the_first_exec[False], a file the test's container had not written yet). The rerun of the failed jobs passed. This PR touches no sandbox code.
  • Round 3 (main merged in f960fae, feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 merged in e23910b, fix 7908d10):

    • The main merge had one conflict, in responses_api_agents/pi_agent/app.py. Since fix(agents): stage activation files inside the close fence #5862, main stages the session's activation files in a files dict, while this PR picks remaining-context.mjs or output-limit.mjs by output_token_policy. The resolution keeps main's files dict and stages whichever plugin the policy picks. Against main, the hunk is only that choice.
    • offline_science.yaml sets sandbox_config.ttl_s: 16200, as feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 does for OpenCode. The 14,400 s TTL from profiles/benchmark.yaml starts when the seed creates the sandbox, but the 14,400 s run budget only starts after the seed, which waits up to 1,200 s for readiness.
    • New responses_api_agents/pi_agent/tests/test_offline_science_presets.py composes hle/pi, hle/pi_search and apex_shortlist/pi as gym eval loads them and validates the agent config. It checks:
      • routing through single_agent_turn_legacy;
      • network_access and absolute_ip_server_types;
      • a loopback head server;
      • Pi 0.85.1 with remaining_context;
      • a TTL that covers the readiness wait plus the run budget.
    • Tests on 7908d10: pytest responses_api_agents/pi_agent/tests responses_api_agents/opencode_agent/tests tests/unit_tests/environment/test_session_harness_benchmark_profiles.py tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py: 1353 passed, 52 skipped.
    • Full unit suite on the main merge, before the fix: 2846 passed, 52 skipped and 1 failed. The failure is pi_agent/tests/test_app.py::test_task_timeout_reaches_local_subprocess_wait, which is flaky on unmodified main too: run alone there, it failed in 3 of 4 runs. It patches asyncio.wait_for globally and expects a single await. This PR does not touch it or the local path it covers.
    • Pre-commit on the changed files: passed.
  • Round 4 (feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 merged in again, 4e989c6, bringing its merge of main):

  • Round 5 (main merged in 5a8650e, after feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 was squash-merged; 3c34792):

    • The branch's copies of feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825's commits conflicted with the squash commit in benchmarks/hle/README.md, benchmarks/apex_shortlist/README.md, opencode_sandboxed_agent/README.md and test_agent_environment_harness_overlays.py. Each file takes main's version plus this PR's own change to it. The resulting diff against main has the same added and removed lines as this PR's commits on top of feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825.
    • 3c34792 only rewords a test comment: the HLE judge leaves loopback in hle/pi_search (see the address note under Rollouts).
    • pytest tests/unit_tests/tooling tests/unit_tests/environment/test_session_harness_benchmark_profiles.py responses_api_agents/opencode_agent/tests responses_api_agents/pi_agent/tests tests/unit_tests/test_public_api_facades.py tests/unit_tests/test_public_api.py on 5a8650e: 2991 passed, 54 skipped. Pre-commit on the changed files: passed.

Rollouts

Real-model pairing runs at 96b0c83 on a workstation's Docker. e65e46a (address scoping and doc fixes) was not re-smoked.

  • Model and harness. nvidia/nemotron-3.5-super-vl-120b-a12b through a hosted endpoint and Gym's vllm_model server, thinking off. Collection used gym env start + gym eval run --no-serve --limit 1, with servers on the docker0 address and the head server on loopback.
  • Image. The offline science image is not on this host. A stand-in image ran install_pi_runtime.sh /opt 0.85.1 on python:3.13-slim, so the preset's sandbox_runtime_dir: /opt path and its version check ran as configured. It has no SciPy, SymPy, Sage or Lean.
  • Smoke-only overrides, applied to a scratch copy of offline_science.yaml and hle/pi_search.yaml; the presets themselves were not changed:
    • the Docker provider instead of OpenSandbox;
    • the stand-in image instead of PI_SANDBOX_IMAGE;
    • network_access: inherit, since Docker cannot restrict egress.
  • Rows. One synthetic row per preset, in the prepared format, because the HLE and APEX data are not in the repo.
Preset Task Result Sandboxes
benchmarks/hle/pi.yaml smallest prime above 1000, checked in Python completed, 1 bash call, answer 1009; HLE judge reward 1.0, mask_sample: false 1 agent-owned; none left after shutdown
benchmarks/hle/pi_search.yaml year Philae landed, with the search tools completed, 1 mcp__tavily__web_search call, answer 2014; reward 1.0, mask_sample: false 1; none left
benchmarks/apex_shortlist/pi.yaml sum of squares 1..30, checked in Python completed, 2 bash calls, \boxed{9455}; symbolic grade reward 1.0, mask_sample: false 1; none left

In all three, the servers saw /seed_session → /v1/agent_sessions → (agent turn) → /v1/agent_sessions/close → /verify → /close_session. The agent session closes before /verify, as single_agent_turn_legacy orders it.

What else the runs show:

  • Pi 0.85.1 under sessions. pi_version reports 0.85.1, harness_execution is sandbox, and the harness hostname is the sandbox container. The outcome parsing handled 0.85.1's output: ng_agent_observations shows the agent invocation completed, with one tool-call record per call.
  • The output_token_policy fix. None of the model requests Pi sent to Gym (3 per run) carried max_tokens or max_completion_tokens. With output-limit.mjs, each call would have asked for the whole 262,144-token window.

Commands to re-smoke the current head on OpenSandbox with the offline science Pi image. Round 3 below ran them with a public image and synthetic HLE rows. Each command takes a gated dataset (Hugging Face token with access in env.yaml), a reachable model endpoint and, for OpenSandbox, the real key and domain. Do not pass reasoning, temperature or an output cap: pi_agent answers 422.

export OPENSANDBOX_API_KEY=<key> OPENSANDBOX_DOMAIN=<domain>
export PI_SANDBOX_IMAGE=<offline science image built from responses_api_agents/pi_sandboxed_agent/offline_science_image>
export TAVILY_API_KEY=<key>   # hle/pi_search only
for b in hle/pi hle/pi_search apex_shortlist/pi; do
  gym eval run --benchmark $b --split benchmark --model-type vllm_model \
      --model <served model name> --model-url <endpoint>/v1 --model-api-key <key> \
      --limit 2 --num-repeats 1 --output results/smoke_${b//\//_}.jsonl
done

What to check:

  • pi_version is 0.85.1 and harness_execution is sandbox;
  • no model request carries max_tokens;
  • each row has a reward;
  • no sandbox is left after the run.

Round 3: OpenSandbox runs on the main merge (f960fae). 7908d10 (TTL and the config test) was not re-smoked, except for the hle/pi_search run, which came later and ran at 7908d10.

  • Model and harness. As in feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825's Round 3: a Nemotron checkpoint served by vLLM through Gym's vllm_model server (thinking on, temperature 1.0, top_p 0.95, all set on the model server). The runs used gym eval run --benchmark <preset> --split benchmark --limit 2 --num-repeats 1 on OpenSandbox, with no default_host. No reasoning, temperature or output cap went into the request.
  • Overrides on the composed agent. The offline science image is not published, so:
    • PI_SANDBOX_IMAGE was python:3.11-slim-bookworm;
    • sandbox_runtime_dir was unset, so Pi 0.85.1 was installed at session start;
    • network_access: inherit, so that install could run.
  • What these runs do not cover.
  • Rows.
    • HLE used two synthetic rows in HLE's prepared format, because the gated dataset was not accessible.
    • APEX Shortlist used its first two prepared rows.
    • hle/pi_search used one synthetic row that asks the agent to look the answer up with web search and name a source. It ran later, at 7908d10, with a real Tavily key; one row only, to stay within the key's quota.
Preset Rows Result Sandboxes left
benchmarks/hle/pi.yaml 2 synthetic both completed; HLE judge reward 1.0, 1.0; mask_sample: false 0
benchmarks/hle/pi_search.yaml (at 7908d10) 1 synthetic, search completed; one mcp__tavily__web_search call; HLE judge reward 1.0; mask_sample: false; pi_version 0.85.1, harness_execution: sandbox; none of its 3 model requests carried max_tokens 0
benchmarks/apex_shortlist/pi.yaml first 2 both completed; reward 1.0, 1.0; mask_sample: false 0
benchmarks/hle/pi.yaml, probe rows 2 probes both completed; reward 1.0, 1.0; mask_sample: false 0

rollouts_failures.jsonl was empty in every run. "Sandboxes left" is the OpenSandbox cleanup tool's dry run, filtered to the run's label.

What else the runs show:

  • Tavily. The search run's one mcp__tavily__web_search call returned real results: 10 ranked hits with URLs and summaries, the first being the Wikipedia article on Philae, and no <error>. The Tavily client returns results only on HTTP 200 and raises Tavily HTTP <status> otherwise, so the call got a 200. The agent's answer cites that article. This is the path the main merge's pi_agent/app.py conflict sits on, with the Tavily Resources server on the host address.
  • Pi 0.85.1 under sessions. Every row reports pi_version: 0.85.1 and harness_execution: sandbox.
  • The output_token_policy fix. None of the 16 captured model requests carried max_tokens or max_completion_tokens. That count covers both Pi's requests and the judge's.
  • Order. Every row has the agent's trajectory, which only /v1/agent_sessions/close returns, and the judge's verdict from /verify. Access logs were off, so the order was not read from the logs.
  • Addresses. Only the model server listened on the host address; the head server and the agent stayed on 127.0.0.1. The port-scan probe from feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825 found no model address in Pi's sandbox files or environment, so it had nothing to scan there. feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825's OpenCode run, which uses the same address settings, covers the scan, and feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions #5825's model_only probe covers the egress policy: it allows the model server's whole host, so keeping the judge on loopback is what keeps it out of reach. That holds for hle/pi and apex_shortlist/pi. In hle/pi_search the judge, a Resources server like Tavily, takes the host address, and model_and_tools opens Tavily's host, so the sandbox can reach the judge's port there.

🤖 Generated with Claude Code

yaoyu-33 and others added 2 commits November 8, 2026 09:27
…gent sessions

benchmarks/hle/opencode.yaml, hle/opencode_search.yaml and apex_shortlist/opencode.yaml now run
opencode_agent through each benchmark's single_agent_turn_legacy Environment Server. Each session
creates its own sandbox from the offline science image, reaching only the model server (and the
Tavily server for search, granted through the agent's tool_servers). The shared settings live in
responses_api_agents/opencode_agent/configs/profiles/offline_science.yaml and follow
opencode_sandboxed_agent's benchmark preset where opencode_agent has the setting; the benchmark
READMEs list what differs (output budget, compaction and step limit, failure handling, command
rules, artifacts).

The relay presets are kept as *_legacy_agent.yaml with deprecation notes, and their citations
(the configuration troubleshooting page, the migration script's message and its routing test)
are repointed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
benchmarks/hle/pi.yaml, hle/pi_search.yaml and apex_shortlist/pi.yaml now run pi_agent through
each benchmark's single_agent_turn_legacy Environment Server. Each session creates its own
sandbox from the Pi offline science image and uses the Pi runtime in it (sandbox_runtime_dir
/opt, pi_version 0.85.1), with the deprecated preset's output policy, compaction setting, Bash
cap and network policy. The shared settings live in
responses_api_agents/pi_agent/configs/profiles/offline_science.yaml; the benchmark READMEs list
what still differs (failure handling, the runtime guard's prompt note, refused request fields,
artifacts).

pi_agent sessions now honor output_token_policy: with remaining_context they load
remaining-context.mjs, which drops each request's output cap, instead of output-limit.mjs. The
setting was applied only to local runs, so a session silently capped every call at
max_output_tokens.

The relay presets are kept as *_legacy_agent.yaml with deprecation notes, and their citations are
repointed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 8, 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.

@yaoyu-33

yaoyu-33 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5ce8169

yaoyu-33 and others added 2 commits November 8, 2026 09:48
…x string

The secrets detector flags the SHA-256 of the image's OpenCode binary in the offline science preset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test efb041d

pi_agent's module exposes no app for uvicorn's extra workers, so the deprecated preset's four
workers never start ("Attribute app not found"), and its session state is process-local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 96b0c83

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior labels Nov 8, 2026
yaoyu-33 and others added 3 commits November 8, 2026 17:17
… server and correct the docs

Scope use_absolute_ip to the model server in the offline science profile, and to the
model and Resources servers in hle/opencode_search, so a sandbox allowed to reach the
model server's host does not also reach the Environment and judge servers bound there.

Docs: list the request fields opencode_agent refuses, scope the shared OpenCode/Pi guide
to the *_legacy_agent presets, update the opencode_agent README for the migrated
presets and the new profile, correct OpenCode's MCP timeout defaults, and point the
Diamond OpenCode header at hle/opencode_legacy_agent.yaml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…r and correct the Pi docs

Scope use_absolute_ip to the model server in the Pi offline science profile, and to the
model and Resources servers in hle/pi_search. List `instructions` among the request
fields pi_agent accepts, say that auto_compaction and output_token_policy apply to
sessions too (and that remaining_context removes the per-call cap), scope the shared
guide to the Pi *_legacy_agent presets as well, and give the one-worker setting its
real reason (no module-level app) and its 512-session ceiling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e65e46a

@weijiac0619

Copy link
Copy Markdown
Contributor

/ok to test 4e989c6

@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

/ok to test 4e989c6

@weijiac0619, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@weijiac0619

Copy link
Copy Markdown
Contributor

/ok to test 4e989c6

@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

Two non-blocking NOTEs correct the OpenCode compatibility documentation. I found no runtime defects in the changed paths.

I reviewed all 28 changed files and traced the affected configuration, session, tool-grant and verification paths. One delegated report wasn't available, so I completed that Pi inspection directly. This was static review; I didn't execute tests or rollouts.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread benchmarks/hle/README.md
- Output budget: 32,768 tokens per model call within a 229,376-token context. OpenCode asks for the output cap on
every call, so the deprecated preset's `remaining_context` policy has no equivalent, and asking for the whole
262,144-token window makes vLLM refuse the call.
- Compaction, the step limit and session titles follow OpenCode's defaults: `opencode_agent` accepts only

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.

NOTE — Suggestion: distinguish unset controls from unsupported controls here and in the APEX copy. Users trying to preserve the old compaction/step settings are told the adapter cannot express them, but _session_opencode_config_error accepts compaction.auto and agent.build.steps. These presets leave them unset. Session titles also aren't left to defaults: the launch command sets NeMo Gym.

Replace the whole bullet in both READMEs with:

  • Compaction and the step limit use OpenCode's defaults because these presets leave compaction.auto and agent.build.steps unset. Sessions support both overrides, but not compaction.prune or agent.title. The step setting requests a final answer; it isn't a hard execution cap. Sessions set the title to NeMo Gym.

Keep the shipped profile unchanged and retain the warning that its settings differ from the deprecated preset. Static acceptance: the text should match the allowlist and launch command. Retain test_compaction_and_build_steps_reach_opencode: auto: false and steps: 8 must reach the generated config in both append and replace modes, without modifying the shared configuration. These are inspected assertions, not execution results.

Comment thread benchmarks/hle/README.md
as 0 (`execution_failure_reward_zero`).
- Commands: `opencode_agent`'s default rules (destructive commands, Git network and history mining) apply, and
subagents stay denied.
- Requests: `opencode_agent` accepts the input, `instructions`, `model`, `temperature` and `top_p`, and refuses

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.

NOTE — Suggestion: document the accepted output-limit cases here and in the APEX copy. With this preset's 32,768-token cap, requests containing max_output_tokens: 32768 or 65536 are accepted, not rejected with 422: _session_input permits limits at least as large as the configured per-call cap. The current wording incorrectly rules out those supported requests.

Replace the request bullet in both READMEs with:

  • Requests: opencode_agent accepts the input, instructions, model, temperature and top_p. A request's max_output_tokens is accepted when it is at least the configured 32,768-token per-call cap; a tighter limit and unsupported controls such as reasoning return 422. This does not implement a total-session token budget.

Change only the documentation; preserve OpenCode's configured cap and Pi's separate rejection rule. Acceptance: retain the existing acceptance test, which accepts request limits of 4,096 and 16,384 while keeping the fixture's configured cap at 4,096, and the tighter-limit test, which returns 422 without consuming the activation. I inspected these checks; I didn't run them.

weijiac0619 and others added 2 commits November 10, 2026 14:59
main now has #5825 as a squash commit, so the branch's copies of #5825's
commits conflicted with it in the HLE and APEX Shortlist READMEs,
opencode_sandboxed_agent/README.md and the relay-recipe routing test.
Each takes main's version plus this branch's own change to it (the Pi
preset and relay-recipe edits); the branch's diff against main is now
only the Pi change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
… test

hle/pi_search sets absolute_ip_server_types to include resources_servers
so the sandbox can reach Tavily, which also moves the HLE judge off
loopback. The comment said the judge stays on loopback in every case;
say that it does except in the search preset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@weijiac0619

Copy link
Copy Markdown
Contributor

/ok to test 3c34792

@weijiac0619
weijiac0619 added this pull request to the merge queue Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42932856354

Merged via the queue into main with commit caa63e5 Nov 11, 2026
119 of 126 checks passed
@weijiac0619
weijiac0619 deleted the yuya/hle-apex-pi-sessions branch November 11, 2026 00:50
weijiac0619 added a commit that referenced this pull request Nov 11, 2026
…_agent sessions

Port of #5702's own changes onto #5826, without the #5458 merge: the five text session presets
(opencode, opencode_search, opencode_reference, pi, pi_search), the relay presets kept as
*_legacy_agent, the local Docker override, the README and the tests. The relay-switch test rows for
hle_diamond move to the *_legacy_agent names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
weijiac0619 added a commit that referenced this pull request Nov 11, 2026
main now contains #5826 (caa63e5). The one conflict, the hle_diamond rows of
test_agent_environment_harness_overlays.py, keeps this branch's *_legacy_agent rows; main's copy
of the file equals #5826's head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
weijiac0619 added a commit that referenced this pull request Nov 11, 2026
…e-diamond-tools

This branch no longer builds on #5458. The second parent is
weijiac/n4p0-hle-diamond-tools-no5458: #5702's presets, tests and README ported onto #5826's
head, moved onto the shared offline science profiles, then merged with main. This commit takes
that tree as is, so the earlier #5458 merges and fixes stay in the history but none of their
content remains, and the diff against main is the reworked change only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
bpritam14 pushed a commit to bpritam14/Gym-evaluation that referenced this pull request Nov 13, 2026
…_agent sessions (NVIDIA-NeMo#5702)

* feat(pi): opt-ins to run Pi in a task sandbox as a harness started there

Benchmarks that grade a harness started inside the task container (Harbor's
agents) need Pi to run with its own tools and prompt, call the benchmark's
model endpoint, and leave logs where the verifier side collects them. Pi's
sandbox sessions could only call a Gym model server with Gym's runtime
guards, and they lost Pi's context-limit outcomes with Pi 0.80.10.

All new settings are off or empty by default, so existing configs behave
as before:

- model_base_url and model_api_key: Pi calls an OpenAI-compatible endpoint
  directly from the sandbox instead of a Gym model server (set exactly one).
  Gym does not capture those calls.
- thinking_level_map and provider_compat for the generated provider, so
  that `--thinking max` can send chat reasoning_effort "max"; settings
  merged recursively over Gym's settings.json (for example retry counts).
- sandbox_env, and sandbox_runtime_guards: false to run Pi's own tools and
  system prompt without Gym's bash cap and prompt note.
- session_prompt_cache_key: one prompt_cache_key per session on every call,
  so a gateway that routes on it keeps the session on one replica.
- sandbox_logs_dir and log_requests: Pi's JSON events (pi.txt), its stderr
  and a per-request log without the conversation in a sandbox directory
  such as Harbor's /logs/agent.
- raise_oom_score_adj: Pi and its tools become the memory-cgroup OOM
  killer's preferred victims, not the exec daemon or the supervisor.
- verify_after_agent_error: a Pi run that failed while its sandbox still
  runs and answers is returned as a gradable failed response, as Harbor
  grades after any agent exit, unless its terminal error is a transient
  model-endpoint failure (after Pi's own retries) or cleanup is unconfirmed.

The runner drops Pi's streaming message_update and tool_execution_update
events, which repeat the whole partial message on every delta, so long
turns no longer grow the event log quadratically. Pi 0.80.10 routes
extension console output to stderr in JSON mode, so outcome.mjs writes its
records to a session file that the runner appends to the event log;
before, context-limit outcomes never reached the adapter in sandbox
sessions. Local runs keep printing them.

The task's HOME, the agent timeout from the task metadata and the
runner's cleanup on capture errors are upstream behaviour and unchanged.

Signed-off-by: gwarmstrong <[email protected]>

* feat(opencode): opt-in direct model endpoint for sandbox sessions

opencode_agent sandbox sessions could only call a Gym model server. A
benchmark that grades a harness started in the task container, as
Harbor runs OpenCode, has the harness call the model endpoint itself,
and routing those calls through a Gym model server changes the requests
the endpoint sees.

model_base_url and model_api_key (both unset by default) point the
session's OpenAI-compatible provider at an endpoint the sandbox reaches,
sending `model` as the model ID; set exactly one of model_server and
model_base_url. Gym does not capture those calls, so the model-call
correlation plugin is not loaded for them. Sessions with a model server
and local calls are unchanged.

Signed-off-by: gwarmstrong <[email protected]>

* feat(opencode): opt-in model request settings for sandbox sessions

A sandbox session's provider sent no reasoning effort, replayed reasoning
only as reasoning_content, capped every call at max_output_tokens and
told OpenCode the model's size, so it compacted before the endpoint's
real limit. A harness started in a task container with its own model
config does none of that, and some endpoints read the replayed reasoning
from another field.

Four settings, whose defaults keep today's requests:

- reasoning_effort: the model's reasoningEffort option, sent as chat
  reasoning_effort on every request.
- interleaved_reasoning_field: the assistant-message field that replays
  each turn's reasoning (default reasoning_content).
- output_token_policy: remaining_context loads a plugin that drops
  max_tokens from the session provider's requests, so the endpoint picks
  the output budget, as opencode_sandboxed_agent's policy of that name
  does.
- declare_model_limits: false leaves the model's size unknown to
  OpenCode, which then compacts only when the endpoint reports an
  overflow.

Signed-off-by: gwarmstrong <[email protected]>

* feat(opencode): opt-in root workdir and argv prompt for sandbox sessions

Two gaps kept a sandbox session from running OpenCode the way a harness
started in the task container does:

- Task images without a WORKDIR start in /, and sessions rejected that
  workdir because the adapter's runtime and session files under /tmp sit
  inside it. allow_root_workdir accepts exactly / (the files stay under
  /tmp, as a harness's own files do there); /tmp and the adapter's own
  directories are still rejected, and other workdirs keep the full
  overlap check.
- A launcher that passes the instruction as one argument, as Harbor
  0.24's opencode agent does, makes `opencode run` wrap it in double
  quotes (inner quotes escaped) before the model sees it. Sessions send
  the instruction on stdin, unquoted. argv_prompt_quoting sends the text
  OpenCode builds from that argument instead.

Both are off by default.

Signed-off-by: gwarmstrong <[email protected]>

* feat(opencode): grade a failed run while its sandbox still runs

Harbor runs the verifier after any agent exit that is not a timeout, so a
trial whose agent died while its sandbox still answers is graded, not
rerun. opencode_agent sessions raised an execution error for every failed
OpenCode run (a nonzero exit, an error on an assistant turn, no terminal
result), so the Environment Server skipped verification and retried the
episode from scratch: an OpenCode the kernel's OOM kill hit, one whose
own pkill hit it, or a request the endpoint rejected.

verify_after_agent_error (off by default) returns such a run as a
`failed` response (`incomplete` when it also hit its time limit), with the
error in metadata.graded_agent_error, which Resources grades as a nonzero
agent exit. It applies only when the supervisor confirmed cleanup, the
run's session export was read, the last assistant turn's error is not a
transient model-endpoint failure (OpenCode's retryable APIError: 429,
5xx, reset or lost connections, header and stream timeouts) and the
sandbox still reports running and answers a probe command. Anything else
stays an execution error and is retried.

raise_oom_score_adj (off by default) makes OpenCode the OOM killer's
preferred victim in its sandbox, as codex_agent's setting of that name
does: the runner raises its own oom_score_adj, which OpenCode and its
tools inherit, to 1000, or to 0 when the sandbox starts it below zero.
The exec daemon and the supervisor keep the sandbox's own score.

Signed-off-by: gwarmstrong <[email protected]>

* feat(claude-code): opt-in instruction on stdin for sandbox sessions

Sandbox sessions pass the instruction to `claude -p` as an argument
after `--`. Harbor 0.24's claude-code agent pipes it on stdin instead,
and on a command line the task's own words are a target: an agent that
runs `pkill -f <word from its task>` stops its own Claude Code.

instruction_on_stdin (off by default) leaves the instruction out of argv
and has the runner feed it to the CLI on stdin from a session file.
Without it, the runner keeps stdin empty, as before.

Signed-off-by: gwarmstrong <[email protected]>

* feat(claude-code): opt-in effort, output cap and client environment

Running Claude Code against a self-hosted model the way its provider's
Claude Code guide configures it needs three client settings the agent
could not express: the reasoning effort (`--effort`, which Harbor passes
from its reasoning_effort), the per-call output cap
(CLAUDE_CODE_MAX_OUTPUT_TOKENS) and further client environment such as
API_TIMEOUT_MS or CLAUDE_CODE_AUTO_COMPACT_WINDOW. A settings file on the
agent host could carry environment, but not from a run config, and not
the CLI flag.

reasoning_effort, max_output_tokens and extra_env (all unset by default)
apply to local and sandbox launches alike. extra_env rejects the
variables the agent sets itself (endpoint, credentials, model,
CLAUDE_CONFIG_DIR, the output cap), and YAML integers become strings.

Signed-off-by: gwarmstrong <[email protected]>

* feat(claude-code): opt-in root workdir for sandbox sessions

A task image without a WORKDIR lends "/" as its working directory, and
sandbox sessions refuse it because the runtime and session files under
/tmp sit inside it, so every such trial fails at session start while a
harness started in the container runs there.

allow_root_workdir (off by default) accepts exactly "/". The runtime and
session files stay under /tmp; /tmp itself, the adapter's own
directories and relative or `..` paths are still refused.

Signed-off-by: gwarmstrong <[email protected]>

* feat(claude-code): opt-in Harbor system-dependency step for sandbox sessions

Before Harbor 0.24 installs Claude Code in a task container, its
claude-code agent runs ensure_system_dependencies for curl, bash, nodejs,
npm and procps: each one whose commands are missing is installed as root
with the first package manager found. Agents graded under Harbor
therefore have node, npm, ps and pkill even where the task image lacks
them, and a sandbox session that skips the step runs Claude Code in a
different environment.

harbor_system_dependencies (off by default) runs the same decisions as
one POSIX sh script (system_dependencies.py: Harbor's checks, package
names, manager order and install command lines, logged line by line)
before the session installs Claude Code, bounded by
system_dependencies_timeout_seconds (default 1800). Where Harbor errors
the trial on a failed install, the session logs the failure and runs
Claude Code anyway. The script's tests run it under real shells with
stand-in package managers.

Signed-off-by: gwarmstrong <[email protected]>

* refactor(pi): read the outcome records from stdout, as main's outcome extension writes them

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): leave model errors the agent reported to the outcome policy

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): keep setup failures ungraded after an agent error

With verify_after_agent_error, Pi and OpenCode graded any failed run while
the sandbox still ran. A run the harness runner could not start (exit 125,
126 or 127), a Pi run whose Gym MCP tools did not load (exit 78), or an
OpenCode run whose required Gym MCP tools did not connect or were never
confirmed is a setup failure: it now stays an execution error and is
retried, never graded as the agent's result.

Signed-off-by: gwarmstrong <[email protected]>

* feat(agents): add swappable benchmark profiles for the session harnesses

The deprecated pi_sandboxed_agent and opencode_sandboxed_agent each ship a
configs/benchmark.yaml profile. A caller that composes a benchmark itself,
such as an evaluation framework that runs HLE, loads that profile instead
of naming a Resources server. The session harnesses that replace them had
no such profile, so moving those callers off the deprecated agents meant
copying the `resources_server.name: ???` binding into the caller, where
some config systems reject a mandatory-missing value.

Add the same profile to pi_agent, opencode_agent, codex_agent,
openclaw_agent, hermes_agent and claude_code_agent, at
configs/profiles/benchmark.yaml. Each leaves the Resources server unset, so
Gym composes the agent onto the benchmark's own agent instance, and each
session creates its own sandbox through the `sandbox` provider at an
absolute address. The Claude Code profile also points the CLI at the
`policy_model` Gym model server. Image, limits and prompts stay with the
caller. Agent discovery reads only the top level of configs/, so, like
opencode_agent's permission profiles, these are not listed as standalone
agent variants.

Signed-off-by: gwarmstrong <[email protected]>

* feat(env): grant MCP tools of extra tool servers to session agents

A session agent got tool grants only from its episode's own Resources
server, so the HLE search presets, which add a Tavily server through
tool_servers, had no session path and stayed on the deprecated sandboxed
agents.

single_agent_turn now takes tool_servers: each episode seeds its own
session on every listed Resources server, with the episode's task data,
grants that server's MCP tools as a required MCPToolAccess, and closes
the session at cleanup. Unset, it falls back to the bound agent's
tool_servers, declared on the base agent config, so a pairing moved off
the legacy_agent relay keeps the tool servers its /run seeded, and a
harness overlay can add search without naming generated instances. As
with the Resources server's own MCP grant, an episode that grants one
restarts from its input after a crash.

Signed-off-by: gwarmstrong <[email protected]>

* feat(pi): restrict the egress of agent-created sandboxes

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]>

* feat(opencode): restrict the egress of agent-created sandboxes

Match pi_agent so reasoning benchmarks without task sandboxes can move
off opencode_sandboxed_agent with the same model-only network:
network_access (inherit, model_only, model_and_tools) sets the
OpenSandbox egress policy on a sandbox OpenCode creates, and a session
that borrows a task sandbox rejects any value other than inherit. It
cannot be combined with sandbox_config.provider_options.network_policy.
The policy comes from the shared restrict_sandbox_network helper,
imported from nemo_gym.agents. The preinstalled runtime path already
exists (sandbox_executable_path).

Signed-off-by: gwarmstrong <[email protected]>

* fix(env): refuse to start with a tool server that cannot serve MCP tools

Startup now also rejects a tool server that is not a Resources server, the
episode's own Resources server, and a Resources server without
expose_tools_over_mcp, each of which otherwise failed every episode.

The partner_if_dispatcher and nooa_agent tests build this server from a bare
client, so they now pass tool_servers=[] instead of reading their agent's.
The README separates the Resources transports from tool-server grants and
says every seeded session is closed.

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): let the benchmark profiles run HLE episodes

Composed onto HLE, every session harness rejected the first seed with a
422. HLE's Environment Server grants the agent its Resources server over
direct_http, which no session harness can use; HLE Diamond, GPQA and
APEX Shortlist do the same. The judge offers the agent no tools, so each
adapter README now gives the pairing setting that clears the grant,
`resources_tool_transports: []` under the benchmark's Environment Server.

The profiles also fill the gaps an episode reached after that:

- Claude Code pins `claude_code_version: "2.1.108"`, which sandbox
  sessions require.
- Each profile declares `sandbox_config` with a mandatory image, so a
  missing image fails at resolve and the image can be set under the
  composed agent's name. All but Hermes set `ttl_s: 14400`, without
  which OpenSandbox ends the sandbox after 10 minutes; Hermes derives
  its TTL from its own timeouts.
- `head_server.host` stays on 127.0.0.1. `use_absolute_ip` otherwise
  puts the head server, whose config endpoint is unauthenticated, on the
  address sandboxes reach.

A new test composes each profile onto HLE, seeds the composed agent with
the request HLE's Environment Server builds, and checks that the seed
reaches sandbox creation with the setting and is refused without it.

Signed-off-by: gwarmstrong <[email protected]>

* fix(configs): grant no tools from judge servers that serve none

equivalence_llm_judge, math_with_judge and mcqa register no tool routes, but
their Environment Servers granted the agent their Resources server over
direct_http, a leftover of NVIDIA-NeMo#4953's switch from the legacy_agent relay. Every
config of these servers binds simple_agent, which accepts a seed with no
grant, so dropping the transport changes nothing for it. A session harness,
which rejects a required direct_http grant, now runs HLE, HLE Diamond, GPQA
and APEX Shortlist without a per-benchmark override.

The adapter READMEs and profile comments drop that override. The profile
test now seeds each composed agent through HLE as shipped, and keeps a case
that grants direct_http to show the 422 still guards pairings whose
Resources server serves tools.

Signed-off-by: gwarmstrong <[email protected]>

* test(agents): seed each profile in its adapter's own suite

The core test that seeded each composed agent imported all six adapters,
so core coverage measured their modules, about 6,700 statements that
only the adapters' own suites exercise, and fell to 87.57%, under its 95%
floor. The seed check now lives in tests/session_harness_profiles.py and
runs from a test in each adapter's suite, in that adapter's environment,
which also runs the Hermes case that the core venv had to skip. The core
test keeps the config-only checks.

Signed-off-by: gwarmstrong <[email protected]>

* fix(claude-code): keep extra_env from re-enabling background tasks

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): keep the profiles' agent server off the sandbox network

use_absolute_ip gave the agent server the address sandboxes reach. An
unseeded request to its /v1/responses runs the harness on the Gym host
with its built-in tools, so a sandbox could start one there. Each profile
now binds its agent to 127.0.0.1, like the head server; only the model
server, which the sandboxes need, takes the reachable address. No
adapter's sandbox calls its own agent server.

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): refuse an unenforceable sandbox network with a 422

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]>

* test(opencode): check that an unenforceable network_access is refused 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]>

* docs(agents): tell harness authors to restrict an owned sandbox's egress

The Add or Update a Harness page and the add-harness skill now say that an
adapter that creates its own sandbox exposes network_access and passes the
spec through restrict_sandbox_network, that settings it cannot enforce are
refused with AgentSeedRejectedError, and that a restricted sandbox gets its
runtime by upload or from a preinstalled sandbox_runtime_dir. They also list
the tests, the model_only pairing run, and an egress exit check, so a new
harness cannot leave a sandbox with open egress on a benchmark graded on the
model's own knowledge.

Signed-off-by: gwarmstrong <[email protected]>

* fix(pi): refuse unusable network and runtime settings with a 422

Addresses the review of the Pi egress change:

- A borrowed session with a restricted network_access, and a preinstalled
  runtime that is missing or runs another version, raise
  AgentSeedRejectedError: a final, logged 422 instead of a retried 500. A
  runtime check that hits a transport error or timeout stays retryable.
- A test covers the MCP-only filter on tool egress: an optional
  direct_http grant opens no host.
- The Pi README describes the runtime directory as copied whole (with
  libstdcpp/ on older Alpine), says a restricted sandbox needs it or a
  prebaked default path, recommends absolute_ip_server_types so only the
  model server leaves loopback, and notes that full isolation needs the
  OpenSandbox dns+nft egress mode.
- The harness guide lists agents/utils/sandbox_network.py and the egress
  notes, and the OpenSandbox page points at restrict_sandbox_network.

Signed-off-by: gwarmstrong <[email protected]>

* feat(pi): restrict the benchmark profile's sandbox to the model server

Addresses the second review of the Pi egress change:

- Pi's benchmark profile sets network_access: model_only, like
  pi_sandboxed_agent's profile, so an HLE or GPQA run that uses it as
  shipped no longer gets open internet. A search preset overrides it with
  model_and_tools. sandbox_runtime_dir is required (???), because a
  restricted sandbox cannot download Pi; null keeps an image prebaked at
  the default path.
- restrict_sandbox_network takes the provider instead of its name, so the
  move to SandboxSpec.egress_rules and provider capabilities (NVIDIA-NeMo#5363) only
  changes the helper's body, not its callers.
- The README says a borrowed sandbox relies on its owner's policy.

Signed-off-by: gwarmstrong <[email protected]>

* test(agents): read each profile's network settings from its own file

The profile tests derive which profiles restrict egress and require a runtime directory from the profiles themselves, so a harness that restricts its profile changes only its own files and the stacked PRs do not conflict.

Signed-off-by: gwarmstrong <[email protected]>

* fix(opencode): align network refusals and the helper call with the reviewed Pi change

restrict_sandbox_network now takes the provider, and a borrowed session with a
restricted network_access is refused with AgentSeedRejectedError, so the 422 is
logged like the other adapters'. OpenCode writes every MCP grant into its config,
so its tool egress already matches the grants it keeps. The README notes that a
borrowed sandbox relies on its owner's network policy. The benchmark profile
keeps inherit: OpenCode installs its runtime from GitHub unless the image
supplies sandbox_executable_path and sandbox_executable_sha256.

Signed-off-by: gwarmstrong <[email protected]>

* test(agents): pin each restricted profile in its adapter's own test

Reading the restricted profiles from the files keeps the stacked PRs apart but cannot catch a profile losing model_only. Pi's own seed-test file now expects model_only and a required runtime directory, so removing either fails it, and the shared helper supplies any harness setting a profile requires (a runtime directory, or a baked binary and its checksum) and checks that each one fails at resolve when unset.

Signed-off-by: gwarmstrong <[email protected]>

* feat(opencode): restrict the benchmark profile's sandbox to the model server

The profile sets network_access: model_only, as the reviewed Pi change does, and requires sandbox_executable_path and sandbox_executable_sha256, because a restricted sandbox cannot download OpenCode. Its own test expects model_only and the required binary, so removing either fails it.

Signed-off-by: gwarmstrong <[email protected]>

* fix(agents): refuse a required tool grant that model_only would block

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]>

* docs(pi): say which grants a restricted seed refuses

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]>

* fix(opencode): refuse a required tool grant that model_only would block

Addresses Yu Yao's review:

- OpenCode passes its required MCP grants to restrict_sandbox_network, so
  under model_only a required grant is refused at seed with a 422 instead
  of failing after the sandbox exists.
- The README and the network_access description say that a restricted
  sandbox needs sandbox_executable_path (or the runtime at the cache path)
  and ripgrep in the image, which grants a restricted seed refuses, and
  that full isolation needs OpenSandbox's dns+nft egress mode.
- The egress test uses a required and an optional MCP grant on different
  hosts plus a direct_http grant that must stay out of the policy, the
  borrowed refusal covers both restricted values, and a route test covers
  the required-grant refusal.

Signed-off-by: gwarmstrong <[email protected]>

* feat(hle_diamond): run the text tool presets as opencode_agent and pi_agent sessions

The opencode, opencode_search, opencode_reference, pi and pi_search presets
leave the legacy_agent relay and the deprecated sandboxed agents. They run
as opencode_agent / pi_agent sessions through each agent's benchmark
profile, driven by the benchmark's own single_agent_turn_legacy
Environment Server. The judge binding and routing name are unchanged.

Each session starts its own sandbox with network_access model_only or
model_and_tools. Such a sandbox cannot download a runtime, so OpenCode runs
the science image's preinstalled binary at the digest its Dockerfile checks,
and Pi runs the Pi image's /opt runtime. Search presets list Tavily in the
agent's tool_servers. Reasoning stays high: OpenCode sets reasoning_effort,
Pi sets thinking high plus provider_compat.supportsReasoningEffort, so Pi
requests now carry reasoning_effort. The environment note moves to
system_prompt, because a session's opencode_config takes only permission
and tools.

opencode_full and opencode_search_full stay on opencode_sandboxed_agent
behind the relay, since sessions take text input only. Their agent is
renamed hle_diamond_opencode_full_agent so sandbox_docker_local.yaml can
override both kinds of agent. README and tests are updated; the relay
switch test drops the four hle_diamond rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* fix(hle_diamond): grade failed session runs and document offline OpenCode limits

The relay presets set execution_failure_reward_zero, so a harness crash,
nonzero exit or deadline became a reward-0 row in the mean. The session
agents default verify_after_agent_error to false, so such a run became a
failure row outside the denominator. opencode, opencode_reference and pi
(and the search presets that compose them) now set it to true, and the
session preset tests check it.

The README now notes that OpenCode stalls about 70 s per start offline
while it tries to install @opencode-ai/plugin (neither science image ships
the plugin dependency bundle), that session presets use opencode_agent's
default permissions instead of '*': allow, and that the harness
transcript under the artifacts directory exists only for the full presets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* chore(hle_diamond): mark the public OpenCode runtime digest for the secrets detector

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* fix(hle_diamond): outlast the seed with the sandbox TTL and record the OpenCode tool-switch blocker

- Session presets set sandbox_config.ttl_s to 16200. The profile's 14,400 s TTL starts when the
  seed creates the sandbox, while the 14,400 s run budget starts only after the seed (up to the
  1,200 s ready wait), so a run near its deadline would lose its sandbox and be retried instead
  of graded. The test now requires ttl_s >= timeout + ready_timeout_s.
- README: a probe shows that OpenCode sessions still run webfetch and task subagents although
  the presets turn them off (tools map), and deny rules under permission after "*": allow did
  not stop them either. Recorded as a blocker under Known limitations; the fix belongs in
  opencode_agent.
- README: Pi creates the session sandbox before waiting for a concurrency slot (keep
  --concurrency at or below 512), the full presets' scores come from a different harness, the
  effort-check request counts match the rebuilt smoke, and the Failed runs bullet is rewrapped.
- Test: opencode_search_full keeps the same Tavily server and environment note as
  opencode_search.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* feat(hle,apex_shortlist): run the OpenCode presets through opencode_agent sessions

benchmarks/hle/opencode.yaml, hle/opencode_search.yaml and apex_shortlist/opencode.yaml now run
opencode_agent through each benchmark's single_agent_turn_legacy Environment Server. Each session
creates its own sandbox from the offline science image, reaching only the model server (and the
Tavily server for search, granted through the agent's tool_servers). The shared settings live in
responses_api_agents/opencode_agent/configs/profiles/offline_science.yaml and follow
opencode_sandboxed_agent's benchmark preset where opencode_agent has the setting; the benchmark
READMEs list what differs (output budget, compaction and step limit, failure handling, command
rules, artifacts).

The relay presets are kept as *_legacy_agent.yaml with deprecation notes, and their citations
(the configuration troubleshooting page, the migration script's message and its routing test)
are repointed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* feat(hle,apex_shortlist): run the Pi presets through pi_agent sessions

benchmarks/hle/pi.yaml, hle/pi_search.yaml and apex_shortlist/pi.yaml now run pi_agent through
each benchmark's single_agent_turn_legacy Environment Server. Each session creates its own
sandbox from the Pi offline science image and uses the Pi runtime in it (sandbox_runtime_dir
/opt, pi_version 0.85.1), with the deprecated preset's output policy, compaction setting, Bash
cap and network policy. The shared settings live in
responses_api_agents/pi_agent/configs/profiles/offline_science.yaml; the benchmark READMEs list
what still differs (failure handling, the runtime guard's prompt note, refused request fields,
artifacts).

pi_agent sessions now honor output_token_policy: with remaining_context they load
remaining-context.mjs, which drops each request's output cap, instead of output-limit.mjs. The
setting was applied only to local runs, so a session silently capped every call at
max_output_tokens.

The relay presets are kept as *_legacy_agent.yaml with deprecation notes, and their citations are
repointed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* fix(opencode_agent): mark the pinned OpenCode digest as an allowed hex string

The secrets detector flags the SHA-256 of the image's OpenCode binary in the offline science preset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* fix(pi_agent): run the offline science preset on one worker

pi_agent's module exposes no app for uvicorn's extra workers, so the deprecated preset's four
workers never start ("Attribute app not found"), and its session state is process-local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* fix(hle,apex_shortlist): keep OpenCode session sandboxes to the model server and correct the docs

Scope use_absolute_ip to the model server in the offline science profile, and to the
model and Resources servers in hle/opencode_search, so a sandbox allowed to reach the
model server's host does not also reach the Environment and judge servers bound there.

Docs: list the request fields opencode_agent refuses, scope the shared OpenCode/Pi guide
to the *_legacy_agent presets, update the opencode_agent README for the migrated
presets and the new profile, correct OpenCode's MCP timeout defaults, and point the
Diamond OpenCode header at hle/opencode_legacy_agent.yaml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* fix(hle,apex_shortlist): keep Pi session sandboxes to the model server and correct the Pi docs

Scope use_absolute_ip to the model server in the Pi offline science profile, and to the
model and Resources servers in hle/pi_search. List `instructions` among the request
fields pi_agent accepts, say that auto_compaction and output_token_policy apply to
sessions too (and that remaining_context removes the per-call cap), scope the shared
guide to the Pi *_legacy_agent presets as well, and give the one-worker setting its
real reason (no module-level app) and its 512-session ceiling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* refactor(hle,apex_shortlist): build the OpenCode offline science profile on profiles/benchmark.yaml

The profile repeated the address, head server, provider, network and sandbox-lifetime settings of
profiles/benchmark.yaml. It now composes that profile and keeps only what the offline science presets
add; the resolved HLE, HLE search and APEX Shortlist configs are unchanged. The mcp_tool_timeout_seconds
comment now gives OpenCode's defaults: 30 s to connect and the MCP SDK's 60 s per call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* refactor(hle,apex_shortlist): build the Pi offline science profile on profiles/benchmark.yaml

The profile repeated the address, head server, provider, network and sandbox-lifetime settings of
profiles/benchmark.yaml. It now composes that profile and keeps only what the offline science presets
add; the resolved HLE, HLE search and APEX Shortlist configs are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

* refactor(hle_diamond): keep the relay presets as *_legacy_agent

Follow the naming of the other agent-session migrations: the session
presets keep the plain names, and each relay preset stays selectable
under its name plus _legacy_agent with a deprecation note naming the
preset that replaces it.

- opencode, opencode_search, opencode_reference, pi and pi_search:
  main's relay presets come back as <name>_legacy_agent.yaml, unchanged
  apart from the header and the config_paths between them. They keep
  their agent names, as the hle presets do.
- opencode_full and opencode_search_full become *_legacy_agent: agent
  sessions take text only, so no session preset covers the full set.
- sandbox_docker_local.yaml documents that it does not compose with the
  text *_legacy_agent presets; a test holds the almost-server error.
- The relay-switch test cites the hle_diamond *_legacy_agent presets
  again, with the agent-name rule of the hle migration.
- README, docstrings and tests use the new names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* fix(hle,apex_shortlist): keep OpenCode session sandboxes through the seed and the full run

The 14,400 s TTL from profiles/benchmark.yaml starts when the seed creates
the sandbox, but the 14,400 s run budget only after the seed, which waits
up to 1,200 s for readiness. A run near its deadline would outlive its
sandbox, and a lost sandbox is retried, not graded. Set the TTL to the run
budget plus 1,800 s, as HLE Diamond's session presets do.

Add a test that composes the three presets as gym eval loads them and
checks the routing, the addresses, the subagent denial, and that the TTL
covers the readiness wait plus the run budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* fix(hle,apex_shortlist): keep Pi session sandboxes through the seed and the full run

The 14,400 s TTL from profiles/benchmark.yaml starts when the seed creates
the sandbox, but the 14,400 s run budget only after the seed, which waits
up to 1,200 s for readiness. A run near its deadline would outlive its
sandbox, and a lost sandbox is retried, not graded. Set the TTL to the run
budget plus 1,800 s, as for OpenCode.

Add a test that composes the three presets as gym eval loads them and
checks the routing, the addresses, the Pi version, the output token
policy, and that the TTL covers the readiness wait plus the run budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* test(pi_agent): scope the loopback note in the offline science preset test

hle/pi_search sets absolute_ip_server_types to include resources_servers
so the sandbox can reach Tavily, which also moves the HLE judge off
loopback. The comment said the judge stays on loopback in every case;
say that it does except in the search preset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* feat(hle_diamond): run the text tool presets as opencode_agent and pi_agent sessions

Port of NVIDIA-NeMo#5702's own changes onto NVIDIA-NeMo#5826, without the NVIDIA-NeMo#5458 merge: the five text session presets
(opencode, opencode_search, opencode_reference, pi, pi_search), the relay presets kept as
*_legacy_agent, the local Docker override, the README and the tests. The relay-switch test rows for
hle_diamond move to the *_legacy_agent names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* refactor(hle_diamond): compose the offline science profiles instead of NVIDIA-NeMo#5458's opt-ins

The session presets now compose responses_api_agents/{opencode,pi}_agent/configs/profiles/offline_science.yaml,
as benchmarks/hle does, and add only the HLE-Diamond judge and dataset; a test holds the agents equal to hle's
apart from those two keys. The search presets let the Resources servers leave loopback and give OpenCode's MCP
calls 300 s, as hle's do.

Dropped, because only NVIDIA-NeMo#5458 defines them: verify_after_agent_error, OpenCode reasoning_effort,
output_token_policy and declare_model_limits, and Pi provider_compat (with `thinking`, which never left the
sandbox without it). OpenCode now asks for 32,768 output tokens per call within a 229,376-token context, as on
hle; a harness crash is retried, then reported as a failed rollout. "Reasoning high" goes on the model server's
extra_body (++policy_model.responses_api_models.<type>.extra_body.reasoning_effort=high), which the README
documents and the Quickstart commands use; the session agents refuse a request `reasoning` field.

The README also records the OpenCode tool probe (webfetch, websearch, task and skill are no longer offered) and
drops "agent sessions take text input only".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* fix(hle_diamond): address review: per-preset effort keys, step-cap wording, config tests

- README: the OpenCode relay presets' effort override names each preset's agent instance
  (hle_diamond_opencode_full_agent, hle_diamond_opencode_reference_agent, hle_diamond_opencode_agent);
  under any other name the override adds an unused agent block and the effort stays high.
- README: the step cap and compaction setting are left unset by the shared offline_science
  profile, not missing from opencode_agent; give the per-run overrides that restore them.
- Headers of the full relay presets name opencode_legacy_agent.yaml and
  opencode_search_legacy_agent.yaml, whose settings they share, instead of the session presets.
- test_hle_diamond.py: drop the tests and asserts that restate preset values (relay wiring, header
  text, the full presets' effort knob, timeout, notes, egress and tool servers per preset,
  config_paths, sandbox_runtime_dir) and compare the Docker override's kept settings with the
  preset itself instead of literals. The routing, schema, hle-equality, image-pin, TTL, deny-order,
  Docker-override refusal and drift checks stay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* docs(hle_diamond): correct the crash-grading and activation-wait notes

A harness crash reaches the Environment Server as a failed agent call, which it
turns into a dependency failure before agent_outcome_policy runs, so no
by_failure_kind setting can grade it; drop the `unknown: verify` workaround.
OpenCode, like Pi, starts a first activation's budget only once it holds a
slot, so its queue wait also runs outside the budget while the sandbox idles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

* refactor(hle_diamond): keep the full presets' names, mark the full-set prepare script legacy

Review: opencode_full.yaml and opencode_search_full.yaml keep their names (they
still run opencode_sandboxed_agent behind the relay); only their agent instance
stays renamed. prepare_opencode.py becomes prepare_opencode_legacy.py, since only
those two relay presets use it. The prepare.py and prepare_text.py docstrings now
say the session presets use prepare_text.py, and the README names the two full
presets wherever it describes the relay presets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

---------

Signed-off-by: gwarmstrong <[email protected]>
Signed-off-by: weijia chen <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: gwarmstrong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>

This branch had an error being deployed

1 failed deployment
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 feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants