Skip to content

feat(harbor): let CLI harnesses take a task's stdio and SSE MCP servers - #6350

Open
adil-a wants to merge 24 commits into
adasif/claude-code-mcp-grantsfrom
adasif/harbor-stdio-sse-mcp-grants
Open

adil-a wants to merge 24 commits into
adasif/claude-code-mcp-grantsfrom
adasif/harbor-stdio-sse-mcp-grants

Conversation

@adil-a

@adil-a adil-a commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PR. This depends on the always-grant-task-MCP PR (#6292) and the Claude Code MCP grants PR
(#6349). Until they merge, the diff against main includes their commits. This PR's own commits are 5fa07946d,
80be9e3b0, c799e6a25, 5f2531e04 and 8c647432b (Hermes SSE wording). The merges d06c02c0d and
196a41d6c bring in the updated heads of the always-grant PR (#6292, 0666e012e) and the Claude Code MCP grants PR
(#6349, c55fb360a), which both include main at 51630ce4f; the merges 3b4b02a40 and 242946fc4 bring in
their next heads (668f194b1 and a96db9200), which both include main at 15adc2254. Head: 242946fc4.

What does this PR do?

A Harbor task can declare stdio, sse (Harbor's default) or streamable-http MCP servers. The harbor
Environment Server granted only streamable-http ones, so CLI harnesses were refused tasks with stdio or SSE servers.
As a maintainer decided, the CLI starts a stdio server itself, as Harbor does, with no bridge in the Environment
Server.

  • Grant model. MCPToolAccess.connection becomes a union keyed on transport: the unchanged
    MCPStreamableHTTPConnection, a new MCPSSEConnection (url, headers) and MCPStdioConnection (command, args, env).
    A connection with no transport still parses as streamable HTTP. Helpers mcp_grants_over,
    unusable_required_grants and mcp_server_urls let adapters keep, refuse and allow-list grants by transport.
  • Harbor server. Every entry becomes a required grant over its own transport. For a stdio entry, the harness's
    MCP client runs command and args in the task sandbox as the agent user. Harbor 0.22's entry has no env or header
    field, so grants carry no task secret. An entry the grant schema rejects is still only warned about.
  • Harnesses. Claude Code (stdio/sse in --mcp-config), OpenCode 1 (local/remote) and mini-SWE take all
    three transports. Codex, Hermes and Pi take stdio but not SSE, so they refuse a required SSE grant with a 422 that
    names it: Codex and Pi have no SSE client, and Gym does not configure SSE grants for Hermes yet (the Hermes pin on
    main, v0.23.2, has an SSE transport). Pi's gym_mcp.mjs gains a stdio transport; the child holds Pi's event loop only while a request
    is pending and is killed when Pi exits. OpenCode 2, Kilo, OpenClaw, CrewAI and OpenHands refuse a required stdio or
    SSE grant and skip an optional one, instead of failing on a missing URL.
  • Docs. The task-folder MCP section gains a transport-per-harness table; the harness contract, Harbor, Compose
    and integration pages and the READMEs follow.

No issue was filed; this follows the maintainer's decision for SkillEvaluator task folders.

Validation

On the head 242946fc4 (main at 15adc2254 merged in through the always-grant PR (#6292) and the Claude Code MCP
grants PR (#6349)), with gym env test (pytest runs serially, one suite at a time):

  • environment_servers/harbor: 741 passed
  • claude_code_agent: 332 passed
  • codex_agent: 633 passed, 9 skipped
  • opencode_agent: 1154 passed, 25 skipped
  • hermes_agent: 407 passed, in a venv built fresh for the merged tree
  • pi_agent: 416 passed, 32 skipped
  • mini_swe_agent: 187 passed
  • miniswe_sandboxed_agent: 213 passed. A first run under load failed 2 native-runner timing tests in test_worker.py; run alternately three times each with one venv, test_worker.py failed 2 of 7 once on this head and 1 of 7 once on main 15adc22542 (the same [timeout] case), and passed the other runs. This PR changes only a comment, a README line and a test docstring in that agent
  • kilocode_agent: 258 passed, 26 skipped
  • openclaw_agent: 570 passed, 2 skipped
  • crewai_agent: 95 passed
  • openhands_agent: 150 passed
  • terminus_2_sandboxed_agent: 174 passed, 4 failed. The 4 are test_terminal.py tmux tests (exited-shell recovery and Ctrl-C queue recovery) that cannot reach a tmux server on the test host; they fail the same way on main 15adc22542
  • root tests/unit_tests/server_runtime (-n 2): 2159 passed, 1 collection error: test_review_boundary_interfaces.py needs cloudpickle, which the dev venv lacks; same on main 15adc22542 in a dev venv built from the same lock

Before that update, pytest -n 8 passed each touched suite, with the same counts on c799e6a25 and 5f2531e04 (a Pi
test fix): Harbor server 741, Claude Code 241, Codex 592 (6 skipped), OpenCode 1017 (9 skipped), Hermes 404, Pi 393
(22 skipped), mini-SWE 187 (needs uv on PATH), Kilo 277 (7 skipped), OpenClaw 561 (1 skipped), CrewAI 95,
OpenHands 150.

  • Pi's node --test suites pass; test_gym_mcp.mjs passes 21 tests and leaves no temp directory behind.
  • OpenClaw's first run, alongside other suites, failed two close-path tests this PR does not touch; they passed
    alone (5 of 5) and in a full rerun.
  • The new tests fail on the base code: 8 Harbor, 4 Pi stdio and 4 Codex tests; other suites fail to import the new
    types.
  • tests/unit_tests on c799e6a25: 23,654 passed and 295 skipped; of the 132 failures and errors, 131 occur the same
    way without this change (missing optional extras, environment-bound tests) and one timing test passes alone
    (3 of 3). A focused core rerun on the final head passed 4,809; its 5 failures and 1 error also occur without this
    change.
  • pre-commit run on the changed files passes every hook.

Rollouts

Runs used a hosted GPT model behind an OpenAI-compatible endpoint, on OpenSandbox, with the tree of c799e6a25;
they were not rerun on the head after the main update. The
stdio task's image holds a stdlib-only MCP server whose get_magic_word tool returns pineapple and logs every call;
test.sh scores 1 only when the answer is pineapple and the log shows the call. The SSE variant serves the same tool
from an HTTP+SSE Compose sidecar. Neither task is in the repo.

Harness Task Result
claude_code_agent, codex_agent (0.144.4), opencode_agent (1.17.11), hermes_agent, pi_agent (0.80.2), mini_swe_agent (mini_swe_agent_sandboxed) stdio 1.0 each
claude_code_agent, opencode_agent SSE 1.0 each; the sidecar logged the SSE handshake and the tool call
codex_agent SSE Refused at seed: ... (Codex has no SSE MCP client); required grants it cannot use: magic (sse)
kilocode_agent (kilocode_sandboxed) stdio Refused at seed: Kilo supports only streamable HTTP MCP tool grants; unsupported required grants: magic (stdio)
oracle (gym dataset validate) stdio, SSE 1.0 each

In the Claude Code and Codex runs, the server log shows the harness started it in the sandbox as the agent user
(root here) with the image's /usr/local/bin/python3; Hermes also ran the image's python3.

After the main update, a combined branch of this PR with the other SkillEvaluator-related PRs, on the same main
(51630ce4f) and with the same resolutions, ran SkillEvaluator tasks whose stdio MCP server's get_magic_word tool
logs each call. On Claude Code, Codex, OpenCode, Hermes and Pi, every one of the 20 MCP rows called the tool and its
grader found the call in the server's log. SSE and streamable HTTP were not exercised there.

Compatibility and benchmark impact

  • Existing grants serialize as before.
  • Tasks with stdio or SSE servers, including a compose_overlay SSE entry, now run on harnesses that speak those
    transports. Other harnesses refuse them at seed and name the grant; before, the server's task-context check refused
    them. mini-SWE now reads these servers from the grant rather than from task.json.
  • Gym's task model mirrors Harbor 0.22, so it does not yet read the headers field newer Harbor MCP entries have.

Not tested

  • A stdio server under a non-root [agent].user.
  • Real runs of mini-SWE over SSE, or of OpenClaw, CrewAI or OpenHands refusing a grant (unit tests only).
  • OpenCode 2 with stdio or SSE: it refuses both; its local-server schema is unverified.
  • A grant env holding secrets: Harbor's entry has no env.

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 (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass). Run on the changed files only.
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

adil-a and others added 5 commits November 18, 2026 01:50
…ants branch

This branch builds on it: Claude Code consumes the stdio and SSE grants
through the same per-session --mcp-config file.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An MCP tool grant could only name a streamable HTTP endpoint. Harbor tasks also declare stdio servers (a command the
agent's MCP client starts) and SSE servers, and SSE is Harbor's default transport for an entry with a URL.

MCPToolAccess.connection is now a union discriminated on `transport`: the unchanged MCPStreamableHTTPConnection, a
new MCPSSEConnection (url, headers) and a new MCPStdioConnection (command, args, env). A connection without a
transport still reads as streamable HTTP. The contract docstring says a stdio server lives with the harness's
session and that adapters stop nothing remote.

Three helpers let adapters handle the transports alike: mcp_grants_over() keeps the MCP grants over the transports a
harness speaks, unusable_required_grants() names the required grants it must refuse at seed (as `name (transport)`),
and mcp_server_urls() gives the hosts a restricted sandbox network must allow (a stdio server needs none).

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…refuse them where unsupported

Each harness that consumes MCP grants now reads the grant's transport instead of assuming a URL.

- claude_code_agent: `stdio` and `sse` servers in the session's --mcp-config, beside `http` ones.
- codex_agent: a stdio grant becomes a config.toml `command` entry; Codex 0.144.4 has no SSE client, so a required
  SSE grant is refused at seed and an optional one is left out with an `mcp_server_skipped` gap. Startup stderr
  redacts a stdio grant's env values as it redacts headers.
- opencode_agent: with OpenCode 1, a stdio grant becomes a `local` server and an SSE grant a `remote` one (OpenCode 1
  tries streamable HTTP, then SSE). OpenCode 2 sessions keep streamable HTTP only and refuse the others.
- hermes_agent: a stdio grant becomes a `command` entry; the pinned Hermes client has no SSE transport, so SSE is
  refused.
- pi_agent: gym_mcp.mjs gains a stdio transport (newline-delimited JSON-RPC to a child process it starts, answering
  the server's pings). The child holds Pi's event loop only while a request waits, is killed when Pi exits, and is
  stopped when its setup fails. SSE is refused.
- mini_swe_agent: its MCP CLI already speaks every transport; a grant now passes its connection's own fields.
- kilocode_agent, openclaw_agent, crewai_agent, openhands_agent: refuse a required stdio or SSE grant at seed with a
  422 that names it and its transport, and leave an optional one out, instead of failing on the missing URL.

A stdio server runs in the sandbox beside the CLI, so it opens no host under `network_access`.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The harbor Environment Server granted only `streamable-http` entries of [[environment.mcp_servers]]; a `stdio` or
`sse` entry (SSE is Harbor's default transport) was warned about and reached only harnesses that read
/tmp/.nemo-gym/task.json, so CLI harnesses were refused such tasks.

Every entry is now a required grant over its own transport, as Harbor hands its agents the list: a stdio entry as
its command and args, which the harness's MCP client starts inside the task sandbox as the agent user (Harbor's
option of letting the CLI launch the server, rather than a bridge in the environment server), an SSE entry as its
URL. Harbor's MCP server entry has no env or header field (0.22), so a grant carries neither and no task secret is
involved. An entry the grant schema rejects is still warned about and left to task.json.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ates

The test that checks a started stdio server is stopped when another required
server fails setup made its pid-file directory with mkdtempSync and never
removed it, so each run left one gym-mcp-pid-* directory in TMPDIR. It now
registers t.after to remove it, as the other temp directories in the file do.

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

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

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5f2531e

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@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

I found one RISK: Hermes rejects an optional SSE grant that its runtime would otherwise skip. I also found one NOTE: the Claude Code README recommends a deleted Harbor setting.

I reviewed all 59 changed files and traced the affected grant, configuration and process-lifecycle paths. This was a static review; I did not execute tests.


Inline comments (escaped v1):

  • responses_api_agents/hermes_agent/app.py line 450: RISK: Filter unsupported optional grants before checking toolset collisions.

    A valid Hermes seed containing {"kind":"mcp","name":"terminal","required":false,"connection":{"transport":"sse","url":"http://memory:9000/sse"}} returns HTTP 422 for a toolset collision. This grant should be skipped: the activation path filters SSE out before configuring Hermes. The collision check still examines every MCP grant, so an unused optional server prevents an otherwise valid episode from starting.

    Could you restrict this comprehension to grants Hermes keeps?

                access.name
                for access in mcp_grants_over(tool_accesses, HERMES_MCP_TRANSPORTS)
                if access.name in TOOLSETS
    

    This keeps required SSE rejection in unusable_required_grants and keeps collision rejection for supported stdio and streamable-HTTP grants, whether required or optional. Only unsupported optional grants bypass the collision check.

    Proposed acceptance checks: seed an optional SSE grant named terminal and assert initialization succeeds and the runner configuration omits it. Keep the supported required terminal rejection in the existing collision test; add equivalent rejection cases for optional streamable-HTTP and stdio grants. Required SSE must still return 422 naming its transport. I have not executed these checks.

  • responses_api_agents/claude_code_agent/README.md line 360: NOTE: Remove the instruction to set the deleted Harbor option.

    Following this paragraph and setting task_mcp_grants: required now prevents Harbor from loading. This PR removes the field, and the configuration regression test explicitly expects ValidationError for that setting. Task MCP servers are now granted as required automatically.

    Could you replace the sentence beginning “The harbor Environment Server refuses” and ending “task_mcp_grants: required” with:

    The harbor Environment Server always grants a task's MCP servers as required. The task_mcp_grants setting has been removed and must be omitted.

    Keep the surrounding distinction between optional failures producing mcp_server_skipped and required failures failing the activation. Keep the earlier network guidance: required HTTP/SSE grants need model_and_tools for an agent-owned restricted sandbox, while stdio needs no tool host.

    Acceptance: inspect the README to confirm it no longer recommends either value of task_mcp_grants. Keep the existing test's assertion that the removed key is rejected. This is a proposed source check, not an executed test.

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

…figures

An optional SSE grant is left out at activation, so its name cannot shadow a
Hermes toolset; checking it refused an otherwise valid seed. Also drops the
Claude Code README's advice to set the removed task_mcp_grants setting.
(Review findings on this PR.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review in f36e207:

  • RISK (Hermes optional SSE grant): the seed now checks toolset collisions only on the grants Hermes configures (mcp_grants_over(tool_accesses, HERMES_MCP_TRANSPORTS)), the same filter activation uses, so an optional SSE grant named after a Hermes toolset no longer refuses the seed. A usable grant with that name is still refused. New test test_seed_ignores_a_toolset_name_on_an_optional_grant_it_will_skip fails on the previous check.
  • NOTE (Claude Code README): dropped the advice to set the removed task_mcp_grants; it now says the Harbor server grants a task's MCP servers as required.

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f36e207

@adil-a

adil-a commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 18, 2026

@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

I found no qualifying issues in this full review. I reviewed all 59 changed files and traced the affected grant, configuration and process-cleanup paths.

Both earlier findings are fixed: Hermes filters unsupported optional grants before checking toolset collisions, and the Claude Code README no longer recommends the removed Harbor setting.

This was a static review. I did not execute tests or independently reproduce the reported rollouts.

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

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 18, 2026
adil-a and others added 5 commits November 22, 2026 22:49
…grants branch

The always-grant branch now includes origin/main (51630ce), so this
brings main in. Conflicts and how they were resolved:

- claude_code_agent (app.py, sandbox.py, README.md, require_mcp_servers.sh,
  tests/test_mcp_grants.py): the same resolution as the Claude Code MCP
  grants branch's merge of main (main's instruction_on_stdin, system
  dependencies and client env next to the MCP grants; the wrapper keeps
  stdin for the backgrounded CLI).
- hermes_agent/app.py: the toolset collision check keeps this branch's
  filter (only grants Hermes configures) and main's builtin_toolsets()
  source. Main moved payload building into _worker_payload, so the
  stdio/streamable-HTTP filter of the MCP grants moved to its caller.
- hermes_agent/tests/test_app.py: main's renamed weather-v1.0 grant plus
  this branch's stdio and optional SSE grants.
- hermes_agent/README.md: this branch's stdio/streamable-HTTP text with
  main's MCP tool naming for Hermes v0.23.2.
- opencode_agent (app.py imports, tests/test_opencode2_session.py): both
  sides' imports and tests kept.
- add-or-update-a-harness.mdx and terminus_2_sandboxed_agent/README.md:
  both sides' text kept.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…E MCP grants branch

Brings the Claude Code test fixes that branch needed on current main
(the fake sandbox's sandbox_id, and required_mcp_servers in main's
run_runner payload). The only conflict, the harness table in
add-or-update-a-harness.mdx, keeps this branch's per-transport rows.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The comment above HERMES_MCP_TRANSPORTS, the 422 for a required SSE
grant and the Hermes row of the harness table said the pinned Hermes MCP
client has no SSE transport. Main's Hermes pin (v0.23.2, ae2a81ccc00e)
does have one (`transport: sse` in tools/mcp_tool_transport.py). The
behavior is unchanged: Gym still refuses a required SSE grant for Hermes
and leaves an optional one out; the texts now say that Gym does not
configure SSE grants for Hermes yet, as the README already does.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…grants branch

The always-grant branch now includes origin/main (15adc22), so this
brings that main as well. No conflicts.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…E MCP grants branch

The Claude Code MCP grants branch now includes origin/main (15adc22),
which this branch already has. No conflicts.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Updated with main at 15adc22542 through the two PRs this one stacks on, and fixed stale Hermes SSE text. New
head 242946fc46:

Conflicts in d06c02c0dc (from main's side):

  • claude_code_agent (app.py, sandbox.py, README, require_mcp_servers.sh, test_mcp_grants.py): the same
    resolution as the Claude Code MCP grants PR's own merge of main (main's instruction_on_stdin, system
    dependencies and client env next to the grants; the wrapper keeps stdin for the backgrounded CLI).
  • hermes_agent/app.py: the toolset collision check keeps this PR's filter (only grants Hermes configures) with
    main's builtin_toolsets() source. main moved payload building into _worker_payload(), so the
    stdio/streamable-HTTP filter of the MCP grants moved to its caller.
  • hermes_agent/tests/test_app.py: main's renamed weather-v1.0 grant plus this PR's stdio and optional SSE grants.
  • hermes_agent/README.md: this PR's stdio/streamable-HTTP text with main's MCP tool naming for Hermes v0.23.2
    (mcp__<server>__<tool>; the PR's old mcp_<server>_<tool> sentence is gone).
  • opencode_agent (app.py imports, test_opencode2_session.py), add-or-update-a-harness.mdx and the Terminus
    README: both sides kept.

In 196a41d6cc the only conflict, the harness table, keeps this PR's per-transport rows.

Fix 8c647432b3: the comment above HERMES_MCP_TRANSPORTS, the 422 for a required SSE grant and the Hermes row of
the harness table said the pinned Hermes MCP client has no SSE transport. main's Hermes pin (v0.23.2,
ae2a81ccc00e) has one (transport: sse). Behavior is unchanged: a required SSE grant is still refused for Hermes
and an optional one left out. The texts now say Gym does not configure SSE grants for Hermes yet, as the README
already did; the 422 test asserts the new message.

These resolutions are the ones the combined end-to-end branch used (all nine SkillEvaluator-related PRs on main
51630ce4f2);
there, a SkillEvaluator task with a stdio MCP server ran on Claude Code, Codex, OpenCode, Hermes and Pi, and the tool
was called in 20 of 20 rows. SSE and streamable HTTP were not exercised there.

Tests on the new head (gym env test, serial, no env.yaml in the tree):

  • environment_servers/harbor: 741 passed
  • claude_code_agent: 332 passed
  • codex_agent: 633 passed, 9 skipped
  • opencode_agent: 1154 passed, 25 skipped
  • hermes_agent: 407 passed, in a venv built fresh for the merged tree
  • pi_agent: 416 passed, 32 skipped
  • mini_swe_agent: 187 passed
  • miniswe_sandboxed_agent: 213 passed. A first run under load failed 2 native-runner timing tests in test_worker.py; run alternately three times each with one venv, test_worker.py failed 2 of 7 once on this head and 1 of 7 once on main 15adc22542 (the same [timeout] case), and passed the other runs. This PR changes only a comment, a README line and a test docstring in that agent
  • kilocode_agent: 258 passed, 26 skipped
  • openclaw_agent: 570 passed, 2 skipped
  • crewai_agent: 95 passed
  • openhands_agent: 150 passed
  • terminus_2_sandboxed_agent: 174 passed, 4 failed. The 4 are test_terminal.py tmux tests (exited-shell recovery and Ctrl-C queue recovery) that cannot reach a tmux server on the test host; they fail the same way on main 15adc22542
  • root tests/unit_tests/server_runtime (-n 2): 2159 passed, 1 collection error: test_review_boundary_interfaces.py needs cloudpickle, which the dev venv lacks; same on main 15adc22542 in a dev venv built from the same lock

@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 242946f

@adil-a

adil-a commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

I reviewed all 62 changed files against the admitted base, including the grant producers, adapter consumers, tests and documentation. The earlier Hermes optional-grant collision fix and Claude Code README correction are still present. I found one narrow RISK: supplementary Unicode in the new Codex stdio fields produces invalid TOML.

CI evidence on 242946fc461b6fa825b12a3fa7731187ab2c1efd: Lint check, Unit tests / Test, all eight server-suite shards, sandbox tests and session-routing end-to-end passed. Build Gym container was skipped. The non-blocking compliance check reported existing run() declarations. The non-blocking mini-SWE conformance job timed out during its validation step, so its scenario results are unavailable.

I ran purpose-built probes on 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, using Python 3.13.14 and Node 22.15.0. Harbor grant conversion and seed round-trips passed for all three transports. Adapter probes preserved arguments, environment values and required/optional filtering. Pi probes passed concurrent-response correlation, late-response isolation and child cleanup. The Codex configuration probe reproduced the finding below; the Claude required-server failure probe stopped promptly. Final Python probes explicitly loaded the admitted source after correcting initial import and fixture mistakes. I did not rerun CI suites or independently repeat the author's model rollouts.


Inline comments (escaped v1):

  • responses_api_agents/codex_agent/app.py line 318: RISK — Preserve supplementary Unicode when serializing the new stdio fields

    Could you make _toml_value() and _toml_key() use TOML-compatible Unicode escaping? The new command, args and env path accepts arbitrary strings, but this json.dumps() emits surrogate-pair escapes for characters outside the Basic Multilingual Plane. TOML rejects those escapes, so an otherwise valid grant makes the generated Codex configuration unreadable, even if that grant is optional.

    My probe through _granted_mcp_servers() and toml_dumps() accepted ASCII and é, but args=["/opt/🍍/server.py"] produced TOMLDecodeError: Escaped character is not a Unicode scalar value. An environment value containing the same character failed too. Run: PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/workspace/review/source python /workspace/review-probes/claude-codex/probe.py.

    The serializer defect predates this PR; the new task-provided stdio fields expose it to these inputs. Emit supplementary characters literally or with TOML \UXXXXXXXX escapes, while preserving escaping for quotes, backslashes and control characters. Add a tomllib.loads() round-trip check over generated stdio configurations containing ASCII, BMP and supplementary Unicode in arguments and environment values, plus quotes, newlines and DEL.

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

…grants branch

The always-grant branch adds one test-only commit (6cd7a66) that drops a
redundant terminus_2_sandboxed_agent test. No conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

I found one RISK: the new connection union's exported JSON/OpenAPI schema disagrees with runtime parsing, breaking schema validation of legacy HTTP grants.

I reviewed all 49 changed files and traced grant producers, adapter consumers, process cleanup, tests and documentation. The earlier Hermes optional-SSE collision, Claude Code documentation and Codex Unicode fixes are still present.

Checks attached to 8c84868d passed Nemo_CICD_Test, lint, all four core-test shards, all eight server-suite shards, sandbox tests and session-routing end-to-end. Build Gym container was skipped. Non-blocking diagnostics remain red: compliance flags unchanged run() methods; Claude Code conformance reports missing evidence and ownership failures; mini-SWE conformance timed out without usable scenario results. I did not establish that this PR caused those conformance failures.

Focused probes ran in the recovered 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline runtime with Python 3.13.14 and Node 22.15.0. Transport conversion, seed round-trips, adapter configuration, Unicode serialization, required-server failure handling and Pi cancellation/child cleanup passed. Schema probes reproduced the finding below. Python probes used actual source models, with extracted methods and fake boundaries where optional runtimes were unavailable. I relied on CI for repository suites and did not repeat the author's model rollouts.

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

Annotated[MCPStreamableHTTPConnection, Tag("streamable_http")]
| Annotated[MCPSSEConnection, Tag("sse")]
| Annotated[MCPStdioConnection, Tag("stdio")],
Discriminator(_mcp_transport),

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: Keep the exported connection schema consistent with the legacy HTTP fallback.

Could you make the generated schema distinguish an omitted transport from an explicit SSE or stdio transport? This discriminated union emits oneOf, but both HTTP and SSE schemas make transport optional. Consequently, the previously valid connection={"url":"http://tools:8000/mcp"} matches both branches and fails JSON-schema validation, although _mcp_transport() correctly parses it as HTTP. Conversely, an untagged {"command":"python3"} passes the exported schema but fails runtime parsing.

My differential probe accepts the legacy HTTP grant against the base schema and rejects it against this head's schema. A minimal FastAPI endpoint using the actual AgentSeedSessionRequest returns HTTP 200 for that request, while its exported OpenAPI request schema rejects the same body. This affects schema-validating clients of the shared agent-session contract, not just one harness.

Please require explicit SSE/stdio tags in the exported validation schema, leaving omitted-tag compatibility only for HTTP, while preserving the intended Python constructor defaults. A schema override or equivalent representation can do that without removing the fallback.

Acceptance: compare runtime parsing with JSON/OpenAPI validation for legacy untagged HTTP, all three explicit transports, untagged stdio, unknown transports and mixed transport fields. The valid cases should agree, and invalid cases should fail on both paths. Probes: connection_schema_probe6350.py, public_schema6350.py and schema_repair_acceptance6350.py under /workspace/review-probes/.

…CP grant schema

The MCP grant connection is a union picked by a callable discriminator that
reads a connection without a `transport` as streamable HTTP. The exported
JSON and OpenAPI schemas render that union as a `oneOf` in which every branch
left `transport` optional, so they disagreed with parsing: an untagged HTTP
connection matched both the HTTP and the SSE branch and failed schema
validation although agents accept it, and an untagged stdio connection passed
the schema although agents reject it.

The SSE and stdio connection models now mark `transport` required, without a
default, in their JSON schema (both validation and serialization modes). The
Python constructors keep their defaults, so `MCPSSEConnection(url=...)` and
`MCPStdioConnection(command=...)` still work, and parsing is unchanged,
including the fallback to streamable HTTP for an untagged connection.

Differential tests check a table of connections (untagged HTTP, each explicit
transport, untagged stdio, Harbor's `streamable-http` and `http` spellings,
an unknown or null transport, and mixed fields) against both parsing and
a standard JSON Schema validator: against the grant model's schema, and
against the agent seed route's OpenAPI request schema with a real POST.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed and fixed in dca2be4.

Cause. MCPConnection is a union picked by the callable discriminator _mcp_transport(), which reads a connection without transport as streamable HTTP. Pydantic exports that union as a plain oneOf, and all three connection models left transport optional (each had a default). So on 8c84868 the exported schema and parsing disagreed in two cases:

Connection Parsing Grant JSON schema /v1/agent_sessions POST That route's OpenAPI request schema
{"url": "http://tools:8000/mcp"} (untagged, valid before this PR) accepted rejected (matches the HTTP and SSE branches) 200 rejected
{"command": "python3"} (untagged stdio) rejected accepted 422 accepted

Every other connection the tests below check already got the same answer on both paths.

Fix (nemo_gym/server_runtime/tool_access.py). MCPSSEConnection and MCPStdioConnection get a json_schema_extra hook. It marks transport as required in their JSON schema and drops its default there, in both validation and serialization modes. MCPStreamableHTTPConnection keeps transport optional, so the only connection that may omit the tag is the HTTP one, which is what the discriminator does. Parsing is unchanged, including the fallback for an untagged connection. The Python constructors keep their defaults: MCPSSEConnection(url=...) and MCPStdioConnection(command=...), which the Harbor server uses to build grants, still work and still dump with their transport. A serialized grant always carries transport, so the serialization schema requiring it is accurate.

Tests. One table of 13 connection bodies is checked on both paths. Valid: untagged HTTP, explicit streamable_http with headers, explicit sse, explicit stdio with args and env. Invalid: untagged stdio, Harbor's streamable-http and http spellings (the grant contract has only streamable_http; the Harbor server maps those spellings before it builds a grant), an unknown websocket transport, transport: null, untagged url plus command, stdio with url, sse with command, and streamable_http with args.

  • tests/unit_tests/server_runtime/test_tool_access.py::test_the_grant_json_schema_accepts_exactly_the_connections_parsing_accepts: MCPToolAccess.model_validate() against jsonschema's Draft202012Validator on MCPToolAccess.model_json_schema(), after check_schema().
  • tests/unit_tests/agents/test_agent_sessions.py::test_the_seed_routes_schema_accepts_exactly_the_grants_it_parses: a real POST of the seed body to an agent's /v1/agent_sessions route (200 or 422) against that route's request schema from app.openapi(), with components resolved.
  • test_a_grant_built_with_default_transports_reaches_json_with_its_transport: grants built with the constructor defaults dump with their transport, validate against the validation-mode and serialization-mode schemas, and parse back unchanged. This one guards the defaults and passed before the fix too.

On 8c84868 the two differential tests fail in exactly the four places shown above: untagged-http and untagged-stdio in each. With the fix all 75 tests in the two files pass.

Not covered: the schema does not express the rule that a URL must be an absolute http(s) URL. format: uri is only an annotation by default, and even with format checking a relative URL such as "/sse" or a non-http(s) URI such as "ws://tools:8000" passes the schema while parsing rejects it. This applied to the HTTP connection before this PR too; the table leaves URL format out.

Validation (no env.yaml in the tree):

  • tests/unit_tests/server_runtime (-n 2): 2173 passed, 1 collection error: test_review_boundary_interfaces.py does not import in the local venv (cloudpickle is not installed there).
  • tests/unit_tests/agents (-n 2): 919 passed, 25 skipped, 5 failed. The same 5 fail with the unfixed tool_access.py. Three test_outcome_policy.py tests need cloudpickle. Two test_sandbox_python.py::test_install_does_not_restore_unmapped_archive_owners cases fail because the local filesystem gives new files the directory's group.
  • environment_servers/harbor tests that build grants (test_app.py, test_compose_overlay.py, test_multi_turn.py, -n 2): 506 passed.
  • claude_code_agent/tests/test_mcp_grants.py: 34 passed.
  • pre-commit passes on the touched files, including import-linter.

Rollout: N/A. Parsing and the grants agents receive are unchanged; only the exported JSON and OpenAPI schemas change.

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dca2be4

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

I found one RISK: Pi's new stdio transport can keep a finished activation alive until its overall timeout when a server stops reading stdin.

I reviewed all 50 changed files, including grant producers, adapter consumers, lifecycle handling, tests and documentation. The previous JSON/OpenAPI schema finding is fixed: differential probes confirmed that legacy untagged HTTP now validates and untagged stdio is rejected. The earlier Hermes collision, Claude Code documentation and Codex Unicode fixes are still present.

Checks on dca2be4f passed Nemo_CICD_Test, lint, all four core-test shards, all eight server-suite shards, sandbox tests and session-routing end-to-end. Build Gym container was skipped. Non-blocking compliance and conformance checks remain red; mini-SWE conformance timed out without usable scenario results. I did not establish that this PR introduced those diagnostic failures.

Focused probes ran in gym:main-offline with Python 3.13.14 and recovered Node 22.15.0. Schema/seed round-trips, Harbor conversion, adapter transport filtering, Unicode serialization, concurrent calls, cancellation and late-response isolation passed. The Pi backpressure probe reproduced the finding below; shutdown cleanup in a scratch copy removed the hang. Probes used actual source models and methods with fake external boundaries where needed. I relied on CI for repository suites and did not repeat the author's model rollouts.

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

});
// The server must not outlive Pi, which ends without waiting for it.
const stop = () => child.kill();
process.once("exit", stop);

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: Close stdio connections when Pi shuts down its session.

Could you close kept connections on Pi's session_shutdown, rather than relying only on this process-exit handler? If a server completes discovery and then stops reading stdin, a large tool argument leaves child.stdin.write() pending. The MCP timeout rejects the call, but the outstanding pipe write keeps Node alive, so the exit handler never runs. I checked the pinned Pi 0.80.2 source: print mode disposes its runtime, emits session_shutdown, then returns without forcing process exit. An otherwise finished activation consequently waits for its overall timeout.

The probe sent a 1 MiB argument to a stalled reader. After the 500 ms MCP timeout it printed CALL TimeoutError, RUNTIME DISPOSED and PRINT EXIT 0, but Node was still alive after four seconds. A small-argument control exited normally. Registering shutdown cleanup in a scratch copy restored exit 0. The shared supervisor bounds the affected activation; this is not an unbounded cross-session leak.

Please retain and close these connections during session shutdown with bounded, idempotent child/pipe cleanup, keeping the exit handler as a fallback. Preserve active-session cancellation isolation so one timed-out call does not unnecessarily kill a usable shared server.

Acceptance: exercise a server that stops consuming stdin after discovery, send a backpressured request, let its MCP timeout expire, then finish print mode. Assert prompt client exit and child termination; retain concurrent-call and late-response isolation. Probe: /workspace/review-probes/pi-current/print_mode_backpressure.mjs.

Pi 0.80.2's print mode emits session_shutdown when a run ends, then
returns without exiting the process. gym_mcp.mjs stopped a stdio server
only from a process exit handler, so a server that stopped reading its
standard input after discovery kept Pi alive: a large tool argument left
a pipe write pending after the MCP timeout, and that write held Node's
event loop until the activation's own timeout.

The extension now stops the stdio servers it kept when the session shuts
down: their waiting calls fail, destroying the child's standard input
drops the writes it has not read, and the server is sent SIGTERM, then
SIGKILL if it has not exited 2 seconds later. Stopping can be repeated,
and the exit handler stays as the fallback for an exit before shutdown.
A call that times out still ends only that call and leaves the shared
server running for later calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed and fixed in 50cd0bc.

Cause. In the pinned Pi 0.80.2, print mode's finally calls runtimeHost.dispose(). That emits session_shutdown (reason quit) and awaits the extension handlers, and then main() returns without process.exit. gym_mcp.mjs stopped a stdio server only from process.once("exit"). The child and its stdout are unref'd while no request waits, but a child.stdin.write() the server never reads is still an active write request, and that keeps Node's event loop alive. So the exit event never came, and the activation ran until its own timeout.

Fix (responses_api_agents/pi_agent/gym_mcp.mjs):

  • registerGymTools now resolves to a function that stops the servers whose tools it registered. The extension keeps that function and calls it from a session_shutdown handler.
  • A stdio connection's close() fails the requests still waiting ("stdio server was stopped"). It destroys the child's stdin, which drops the writes the server has not read, and its stdout. It then sends SIGTERM, and SIGKILL if the server has not exited 2 seconds later (STOP_GRACE_MS). It resolves when the server exits or when SIGKILL is sent. A second call returns the same promise, so shutdown can run more than once.
  • The process.once("exit") handler stays as the fallback for an exit before shutdown, for example the setup-failure process.exit(78) or a SIGTERM that arrives while discovery is still running. A SIGTERM later in the run goes through Pi's own shutdown, which emits session_shutdown first, so the server is now stopped there too. It is removed only once the server has exited or been sent SIGKILL.
  • Cancellation isolation is unchanged. A call that times out or is cancelled only stops waiting for its own id, and the shared server keeps running for other calls.
  • The README now says when a stdio server is stopped.

Tests (responses_api_agents/pi_agent/tests/test_gym_mcp.mjs, run with node --test by test_app.py::test_gym_extensions):

  • At session shutdown, a stdio server that stopped reading is stopped, and Pi exits. This runs in its own Node process, in the order Pi's print mode uses. The stub server answers discovery, then pauses its stdin. The test then:

    • runs session_start;
    • sends a 1 MiB tool argument, which rejects with TimeoutError after the 500 ms MCP timeout;
    • calls session_shutdown twice;
    • returns with no process.exit.

    It asserts that the process exits by itself with status 0 inside a 10 s bound, that shutdown took under 2 s, and that the server's pid is gone.

  • The same with a server that ignores SIGTERM. Shutdown takes at least the 2 s grace, then the server is killed with SIGKILL, the client exits 0, and the pid is gone.

  • A timed-out stdio call leaves the shared server usable and its late answer unread. The server holds the answer to one call. Two calls made meanwhile get their own results. The held call times out, and the server is still alive. The next call makes the server send the held call's late answer first and then its own, and the next call gets its own answer, not the late one. A further call also succeeds.

  • Stopping the kept stdio servers fails their waiting and later calls, and can be repeated. This covers a call waiting when the stop happens, a call after it, and two stops at once followed by a third.

The final test file run against the extension at dca2be4 gives 22 passed and 3 failed in 26.7 s. Both shutdown cases fail with "the client did not exit by itself", killed at the 10 s bound. The stop test fails because registerGymTools returned nothing. The isolation test passes there too, as a guard for behavior that was already correct. With the fix, all 25 pass in about 5 s, in each of six runs.

Pinned Pi end to end. I ran the real Pi 0.80.2 CLI (--print --mode json --no-session) with this extension. A local streaming model's first reply calls the stalled server's tool with a 1 MiB argument (MCP timeout 500 ms), and its second reply answers in text. The run had a 15 s bound.

gym_mcp.mjs Tool result Model calls agent_end Pi exit Wall time Server after
dca2be4 timeout error 2 yes killed at the 15 s bound 15.0 s still running
50cd0bc (3 runs) timeout error 2 yes status 0 2.64 to 2.70 s gone

Other checks. I ran the Pi agent suite (pytest -n 2) with Node 22.19.0 and the pinned Pi 0.80.2 on PATH, so the Node-gated and pinned-Pi tests ran instead of skipping. Result: 448 passed, 0 skipped. A rerun failed one test this PR does not touch (test_close_confirms_cleanup_before_provider_cancellation, a race reading children.json that comes from main); it passed 5 of 5 times alone. That includes the real-Pi activations (test_pinned_pi_ends_the_run_on_finish, test_pinned_pi_stops_before_inference_when_a_required_grant_is_down, and the context-overflow ones). pre-commit passes on the changed files, and no stub or Pi processes were left running.

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 50cd0bc

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

LGTM — no concerns found. I reviewed all 50 changed files, including grant producers, adapter consumers, lifecycle handling, tests and documentation.

The prior Pi backpressure finding is fixed. A differential probe reproduced the hang on dca2be4f. On 50cd0bc4, repeated session shutdown exited successfully and terminated both normal and SIGTERM-ignoring stdio servers. Cancellation and late-response isolation still passed. The earlier schema compatibility, Hermes collision and Codex Unicode fixes are intact.

Checks attached to 50cd0bc4 passed lint, all eight server-suite shards, sandbox tests, session-routing end-to-end and core-test shards 0, 1 and 3. Core-test shard 2 was still running at the final read, so I have not observed a passing aggregate verdict. Non-blocking compliance and conformance checks are red. Compliance flags existing run() declarations; conformance reports ownership and evidence failures. I did not establish that this PR introduced those diagnostic failures.

Focused probes ran in gym:main-offline with Python 3.13.14, Pydantic 2.13.4 and Node 22.15.0. They passed schema/seed compatibility, Harbor conversion, transport filtering, configuration preservation, Unicode serialization and Pi shutdown/cancellation cases. Probes used actual source models and methods, with extracted methods and fake external boundaries where optional runtimes were unavailable. I relied on CI for repository suites and did not independently repeat the author's model rollouts.

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

… test

test_shutdown_kills_descendant_after_its_wrapper_exited failed intermittently on main and in CI:
- It read the child's pid as soon as the pid file existed, but the child creates the file before it writes its pid,
  so the read could be empty (ValueError).
- It checked psutil.pid_exists and then asked psutil.Process for the status, so a child that exited in between
  raised NoSuchProcess.
The test now waits for the pid itself, and treats a process that is gone when it is looked up as stopped, like a
zombie. 30 of 30 runs pass locally, where it failed 2 of 6 on main before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

4ee75f0f78 fixes a flaky test that failed this PR's core shard twice: test_shutdown_kills_descendant_after_its_wrapper_exited (tests/unit_tests/server_runtime/supervisor), which this PR does not otherwise touch and which also failed 2 of 6 local runs on main. It had two races: it read the child's pid file before the pid was written, and it called psutil.Process(pid).status() after pid_exists without handling a child that exited in between. It now waits for the pid itself and treats a process that is gone as stopped. 30 of 30 local runs pass; the file passes (18).

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4ee75f0

@adil-a

adil-a commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

LGTM — no concerns found. I reviewed all 51 changed files against the admitted base, including grant producers, adapter consumers, process cleanup, tests and documentation.

The earlier schema compatibility, Hermes optional-grant collision, Codex Unicode and Pi shutdown findings stay resolved. The only change since the previous review fixes two races in the supervisor shutdown test without weakening its process-termination assertion.

On 4ee75f0f, Lint check, Unit tests / Test, all four core shards, all eight server shards, the Server suite aggregate, sandbox tests and session-routing end-to-end passed. Non-blocking compliance and conformance checks are red. Compliance flags agent run() declarations; mini-SWE conformance reports provider timeouts and missing or invalid evidence. I did not establish that this PR introduced those diagnostic failures.

Focused probes passed in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, with Python 3.13.14, Pydantic 2.13.4 and Node 22.15.0. They exercised Harbor grant conversion, runtime/JSON/OpenAPI compatibility, adapter filtering and configuration preservation, Unicode serialization, required-server failure handling, and Pi backpressure shutdown and cancellation isolation. Probes used actual source models and methods with fake external boundaries where needed. I relied on CI for repository suites and did not independently repeat the author's real-model rollouts.

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

adil-a and others added 2 commits November 27, 2026 10:50
…nto adasif/harbor-stdio-sse-mcp-grants

Conflicts with main, each resolved keeping both sides:
- nemo_gym/server_runtime/__init__.py: this branch's MCPTransport export next to main's OwnedSandboxes and
  sandbox_borrow exports.
- codex_agent/app.py: this branch's CODEX_MCP_TRANSPORTS, grant secret and TOML string helpers next to main's
  exact-version and [agents] version constants and _version_numbers.
- openhands_agent/app.py: this branch's OPENHANDS_MCP_TRANSPORTS next to main's comment, which no longer names an
  SDK version.
- openclaw_agent/README.md: this branch's per-transport grant text with main's tool-search and probe exit text for
  OpenClaw 2026.11.5.
- opencode_agent/README.md: this branch's per-transport grant text with main's tool-name collision text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
…e configures

main's check for two MCP grants whose tools OpenCode could register under one name selected the grants with
isinstance(access, MCPToolAccess). This branch no longer imports MCPToolAccess in the OpenCode adapter, so after
the merge of main every sandbox seed failed with a NameError (41 failed tests in opencode_agent).

The check now runs over mcp_grants_over(..., self._mcp_transports), the grants OpenCode configures: every MCP grant
for OpenCode 1, streamable HTTP grants for OpenCode 2, which leaves an optional SSE or stdio grant out and registers
no tools for it. A test for each case: OpenCode 1 still refuses an SSE or stdio grant whose tools could share a
name with another grant's, and OpenCode 2 keeps a session whose only such grant is one it leaves out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated with main at 66a0698b3c through the two PRs this one stacks on, plus one fix. Head now 8ed16773f6:

Conflicts in a98877ef07, each resolved keeping both sides:

  • nemo_gym/server_runtime/__init__.py: this PR's MCPTransport export next to main's OwnedSandboxes,
    BorrowedSandbox, BorrowedSandboxError and borrow exports. In tool_access.py, which merged on its own,
    MCPToolAccess.name keeps main's MCP_TOOL_ACCESS_NAME_PATTERN and connection this PR's MCPConnection.
  • codex_agent/app.py: this PR's CODEX_MCP_TRANSPORTS, grant secret and TOML string helpers next to main's
    exact-version and [agents] constants and _version_numbers (model catalog and agents_enabled). main's
    model_catalog_json goes through this PR's _toml_string like every other string. main's SandboxAccess.env
    forwarding sets the Codex process environment; a stdio grant's env stays per server in config.toml.
  • openhands_agent/app.py: this PR's OPENHANDS_MCP_TRANSPORTS above main's comment, which no longer names an SDK
    version (SDK 1.62.0). Below it, main's millisecond timeout and this PR's transport filter merged on their own.
  • openclaw_agent/README.md: this PR's per-transport grant text with main's OpenClaw 2026.11.5 text (tool search
    turned off so grant tools stay <grant>__<tool>; the probe's exit codes).
  • opencode_agent/README.md: this PR's per-transport text (OpenCode 1 remote and local servers, OpenCode 2
    streamable HTTP only) with main's refusal of two grants whose tools OpenCode could register under one name.

Fix 8ed16773f6: main's OpenCode check for two such grants selects grants with
isinstance(access, MCPToolAccess). This PR had replaced every such test with mcp_grants_over and no longer
imports MCPToolAccess in opencode_agent/app.py, so after the merge every sandbox seed failed with a NameError
(41 failed opencode_agent tests on a98877ef07). The check now runs over the grants OpenCode configures,
mcp_grants_over(..., self._mcp_transports): every MCP grant on OpenCode 1, streamable HTTP grants on OpenCode 2,
which leaves an optional SSE or stdio grant out, so that grant registers no tools that could collide. Two tests
added: OpenCode 1 still refuses an SSE or a stdio grant whose tools could share a name with another grant's, and
OpenCode 2 keeps a session whose only colliding name is an optional SSE grant it leaves out. ruff check --select F821 over the changed Python files of this stack and of the task-skills and network-mode PRs finds no other
undefined name.

Tests (gym env test, serial; root tests -n 2; no env.yaml in the tree). The fix touches only
opencode_agent; the Harbor, Claude Code, Codex and Hermes suites ran on a98877ef07, the rest on 8ed16773f6:

  • environment_servers/harbor: 761 passed
  • claude_code_agent: 332 passed
  • codex_agent: 681 passed, 9 skipped
  • opencode_agent: 1259 passed, 28 skipped (41 failed on a98877ef07, before the fix)
  • hermes_agent: 426 passed
  • pi_agent: 435 passed, 38 skipped
  • mini_swe_agent: 187 passed
  • openhands_agent: 150 passed
  • openclaw_agent: 746 passed, 15 skipped
  • kilocode_agent: 258 passed, 26 skipped
  • crewai_agent: 95 passed
  • root tests/unit_tests/server_runtime: 2357 passed, 1 collection error: test_review_boundary_interfaces.py needs
    cloudpickle, which the dev venv lacks; same on main 66a0698b3c in the same venv
  • root tests/unit_tests/agents: 923 passed, 26 skipped, 5 failed; the same 5 fail on main 66a0698b3c in the same
    venv: 3 outcome-policy upload-evidence tests need cloudpickle and 2 sandbox_python archive-owner tests depend on
    the host's gid mapping

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8ed1677

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

…a loaded runner

The test gave the whole stdio server a 300 ms call timeout so the held call times out quickly, but the calls answered
at once ran under the same limit and timed out on a loaded CI runner. The server timeout is now 2 s: only the held
call waits it out. 12 of 12 local runs pass with six test processes at a time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

0312e8dc5b fixes a CI-only failure in a test this PR adds (test_gym_mcp.mjs, "a timed-out stdio call leaves the shared server usable"): the whole stdio server had a 300 ms call timeout so the held call would time out fast, but the calls that answer at once shared that limit and timed out on a loaded runner. The server timeout is now 2 s, so only the held call waits it out. 12 of 12 local runs pass with six test processes running at once.

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0312e8d

@adil-a

adil-a commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

LGTM, no concerns found. I reviewed all 51 changed files, with separate reviews of Harbor/shared contracts, Python adapters and Pi lifecycle behavior. I traced grant production, configuration consumers, process cleanup, tests and documentation.

I compared against the reachable previous-review commit 4ee75f0f. The earlier schema compatibility, Hermes optional-grant collision, Codex Unicode and Pi backpressure/shutdown findings stay resolved. The latest timeout adjustment keeps the test's concurrent-call and late-response assertions intact.

The checks attached to 0312e8dc passed lint, all four core shards, combined coverage, all eight server shards, sandbox tests, LongMT scoring and session-routing end-to-end. Both Unit tests / Test and Unit tests / Server suite are green. Changed server tests was skipped, not passed. Non-blocking compliance reports existing run() declarations; OpenClaw and mini-SWE conformance timed out after five minutes without usable scenario results. I did not establish that this PR introduced those conformance failures.

Purpose-built CPU probes passed in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:82ded40c139ecf82e8053592f13b40e70f98eef4, the verified default-branch CI image because no head image was available, using Python 3.13.14, Pydantic 2.14.4 and Node 24.19.0. They exercised runtime/JSON/OpenAPI agreement across 80 connection cases, Harbor conversion, adapter filtering and configuration preservation, Unicode TOML round-trips, and Pi cancellation isolation, child failure and backpressured shutdown. The actual-source probes used fake external boundaries.

An auxiliary fake-agent lifespan probe timed out after 180 seconds and is inconclusive; the separate real-route/OpenAPI probe passed. Initial image-import mismatches were corrected before the successful probes. I relied on CI for repository suites and did not repeat the author's real-model rollouts.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high 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