Repository navigation
fix(mcp): show verifiers an MCP tool's own name under every harness - #7070
cwing-nvidia wants to merge 12 commits into
Conversation
…servers Each harness shows its model an MCP tool under its own name (Claude Code mcp__<server>__<tool>, OpenClaw <server>__<tool>, older Hermes mcp_<server>_<tool>), and a verifier that compares tool names literally scored the same call differently per harness. Hermes and Pi each carried a private rename; OpenClaw had none, so its MCP calls reached verify as <server>__<tool>. Add nemo_gym.agents.mcp_tool_names: an adapter declares its harness's scheme as an MCPToolNaming, and name_mcp_tool_calls renames a response's MCP calls to Gym's mcp__<server>__<tool>, which the tool's resources server already strips before verify. Names are resolved against the MCP servers Gym configured for the session, not split on a separator, so server and tool names that hold underscores resolve exactly. Use it in the OpenClaw adapter (new), the Hermes adapter (replacing its private helper, same behavior) and Claude Code's /run (restores a server name Claude Code rewrote). The verify request and response are unchanged. Refs #2668 Signed-off-by: Chris Wing <[email protected]>
The first commit renamed MCP calls in the response, so a stored rollout lost the name the model emitted. Adapters now leave function-call names as emitted and record, in the response's nemo_gym_mcp_tool_identities metadata, the configured server and tool each emitted name stands for. A resources server that serves its tools over MCP reads that record in its /verify wrapper, scores the tool's own name, and restores the emitted names in what is stored. BaseVerifyRequest and BaseVerifyResponse are unchanged. Resolution is exact against the session's servers: a name that more than one server's prefix matches, or that the harness may have cut, is not resolved. OpenClaw's server-name rewriting (sanitizing, mcp- prefix, 30-character cap, numbering) and 64-character bound are ported from its 2026.6.11 source; Hermes gets its 64-character clamp guard. Pi, Hermes, OpenClaw, OpenCode, Kilo and Claude Code now share nemo_gym.agents.mcp_tool_names; Pi's and Hermes' private helpers are gone. Rollouts stored without a record: /verify still strips mcp__<server>__, and now also accepts this server's own <server>__, <server>_ and mcp_<server>_ aliases when what follows is one of its tools and the whole name is not. Refs #2668 Signed-off-by: Chris Wing <[email protected]>
…fiers A verifier that checks for a tool call had to know how the harness names an MCP tool for its model. The agent adapter's record of the server and tool behind each emitted name was applied only in a resources server's /verify. Carry it where the other readers look: - Each tool attempt of a rollout's trajectory has mcp_server and mcp_tool beside tool_name, which stays the name the model emitted. - The trajectory file a task folder's verifier reads, and the ATIF export of a saved rollout, name such a call by the tool's own name, with mcp_server and emitted_name under extra.nemo_gym. The record's reader moves to nemo_gym.core so the trajectory package can use it. Refs #2668 Signed-off-by: Chris Wing <[email protected]>
…by their own names - A tool span and the tool metrics name an MCP tool by its own name; the span keeps the emitted name and the server beside it. - A name that belongs to one of the session's MCP servers but cannot be resolved, because the harness may have cut it or two servers match it, is recorded on the response and becomes an mcp_tool_name_unresolved observation gap. - A resources server that serves its tools over MCP warns at startup about tools whose name, with the server's, reaches the 64 characters where a harness may cut it. - Glossary: tool's own name, emitted name. Refs #2668 Signed-off-by: Chris Wing <[email protected]>
The tutorial listed how two harnesses name MCP tools, which goes stale when a harness changes. Say what a verifier checks for and point to each agent's README. Tell harness authors to cover their naming with a transcript from the pinned harness version. Signed-off-by: Chris Wing <[email protected]>
Signed-off-by: Chris Wing <[email protected]>
Found in review of the branch: - /verify still guessed at a name the agent adapter had recorded as unresolved, through the alias fallback for older rollouts. - A harness tool of its own whose name starts like the server's, such as store_fetch beside a server named store, was recorded as that server's tool and shown to the verifier as fetch. The server now takes a recorded tool only when it serves a tool of that name. - Agent adapters import MCPToolNaming and record_mcp_tool_identities from nemo_gym.agents, the package's public API. - Annotations in the added code use X | None. Signed-off-by: Chris Wing <[email protected]>
The MCP tutorial and the harness guide already say which name a verifier checks for. Signed-off-by: Chris Wing <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test c953741 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
I found one BLOCKER and two RISKs. ATIF reverification can credit a foreign server’s tool call to the verifier’s own server. The identity propagation also misses child-only calls and earlier activations in continued sessions.
I reviewed all 34 changed files and connected consumers with three delegated topic reviewers.
Validation:
- I relied on successful head CI checks:
Lint check,Nemo_CICD_Test,Unit tests / Test,Unit tests / Server suite, andUnit tests / Combined core coverage. Core/server shards, sandbox tests, and session-routing tests also succeeded. Harness conformance and environment compliance have nonblocking failures; I have not attributed those failures to this change. - CPU probes ran in
766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:146389feffb52af5b4cfd138b5c89fe5dc123016, the default-branch CI image. The head’s container build was skipped. Identity serialization, verify echo/reverification, ambiguity handling, partial responses, and normal ATIF projection passed the focused probes. - A base-versus-head HTTP verifier probe reproduced reward changing from 0 to 1 after ATIF export/reverification only on head. Mocked Kilo/Hermes adapter probes reproduced missing child identities. A cumulative-session probe reproduced missing earlier identities and unresolved-name gaps.
I did not rerun green repository suites or execute real harness/model rollouts.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
nemo_gym/trajectory/atif_reverification.pyline 383: BLOCKER: Preserve MCP server identity during ATIF reverification.The exporter now writes the bare tool name into
function_nameand keeps its server inextra.nemo_gym. This unchanged consumer copies onlyfunction_name, so the server distinction disappears. A call toother.get_weatherthen reaches theweatherverifier as its ownget_weather.I reproduced this through
build_atif_verify_payloadand a real FastAPI/verifywrapper using/workspace/review-probes/leader/probe_atif_reverify.py. On head, direct reward is0.0and the exported/reverified reward is1.0; both rewards are0.0on the admitted base. This silently changes scores for exported MCP rollouts.Could you consume the per-call MCP identity when rebuilding the response? Restore distinct server-qualified names, or emitted names plus identity metadata, and keep that information through the materialized-request overlay. A map keyed only by the bare name cannot distinguish two servers sharing it. Keep bare names in the task-verifier ATIF file and preserve ordinary ATIF documents without this extension.
Acceptance: round-trip both live and saved exports containing
weather.get_weatherandother.get_weather; direct and reverified rewards must agree, and only the weather server’s call may receive credit. -
nemo_gym/agents/mcp_tool_names.pyline 111: RISK: Resolve child-only tool calls from the observation bundle too.This loop scans only the root
response.output. Kilo deliberately keeps child output in its family observations, as its existing separation test shows. Hermes also imports delegated tool calls separately from the root response. A tool used only by a child therefore never enters the identity map, so the new trajectory, ATIF, and telemetry paths keep its harness-specific name.Mocked production-adapter probes confirm this for both harnesses.
/workspace/review-probes/mcp-identity-1/child_kilo_probe.pyproducesrecorded identities: {}andgrandchild weather_get_weather None Nonedespite a configuredweathergrant. The Hermes delegation probe produces the same missing MCP fields.Could you resolve the collected observation tool names with the same naming scheme and record their identities and unresolved gaps before trajectory assembly? Keep emitted names intact and keep child output separate from the root response.
Acceptance: child-only Kilo and Hermes MCP calls must carry
mcp_server='weather'andmcp_tool='get_weather', with canonical export/metric names. Cover an unresolved child call and an ordinary non-MCP child tool while retaining the root-output separation test. -
nemo_gym/rollouts/trajectory_builder.pyline 562: RISK: Enrich every activation in a continued episode.This reads identities and unresolved names only from the final
response. Harbor’s continued-episode result combines the last activation’s response with the whole session’s observations and trajectory. Earlier tool names absent from the final response therefore get no MCP identity, and earlier unresolved-name markers disappear./workspace/review-probes/leader/probe_cumulative.pyreproducesweather__get_weatherretaining(None, None)while the final activation’sweather__forecastresolves. An unresolved marker retained on the first turn produces no finalmcp_tool_name_unresolvedgap. Metrics and exports consequently depend on which tools the last activation repeats.Could you attach identities and unresolved gaps to activation-owned evidence before accumulation, or consume the retained per-turn responses with their invocation ownership? Preserve emitted names and avoid assigning one activation’s identity to unrelated attempts by name alone.
Acceptance: a two-activation continuation that calls different MCP tools must retain both identities and canonical metric/export names. An unresolved call in the first activation must still appear as a gap after the second activation.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
…bagents and continued sessions From review: - Rebuilding a response from an exported trajectory took only function_name, the tool's own name, and dropped its server. A call of another server's tool of the same name was then credited to the verifying server. The response now gets the emitted name back with the record of its server and tool, and the record survives the task's own request metadata. - The record was built from the response's own tool calls. Calls a subagent made, and calls of earlier activations of a continued session, are only in the session's observations. An agent that declares mcp_tool_naming now has every observed tool call resolved when its session closes, with unresolved names added as gaps there. Signed-off-by: Chris Wing <[email protected]>
|
/ok to test 69f55e7 |
Conflict in nemo_gym/agents/base_responses_api_agent.py: both sides added imports beside agent_outcome. Kept main's and this branch's. Signed-off-by: Chris Wing <[email protected]>
|
/ok to test 5e01928 |
Conflict in responses_api_agents/claude_code_agent/app.py: main added classify_outcome at the top of ClaudeCodeAgent, where this branch declares mcp_tool_naming. Kept both. Signed-off-by: Chris Wing <[email protected]>
|
/ok to test 60370d9 |
Conflicts in nemo_gym/agents/base_responses_api_agent.py and responses_api_agents/opencode_agent/app.py: main and this branch each added an import on the same line. Kept both. Signed-off-by: Chris Wing <[email protected]>
|
/ok to test 9eadac5 |
Summary
A verifier that checks for a tool call has to know how each harness names an MCP tool for its model. The same tool,
get_weatheron a server namedweather, reaches a verifier asmcp__weather__get_weather,weather__get_weather,weather_get_weatherorget_weather, depending on the harness. A verifier written against one harness reports a false failure under another, and on main a task folder's verifier gets the raw harness name under every harness.With this change a verifier checks for the tool's own name,
get_weather, under every harness. The rollout keeps the name the model emitted.Closes #2668. Supersedes #2673, which carried the tool's identity on the verify request and no longer fits main, where the environment server calls
/verifyand task folders have no resources server.What changed
Each agent adapter declares how its harness names an MCP tool (
MCPToolNaming) and records, in the response's metadata, which server and tool each emitted name stands for. Names are resolved against the MCP servers Gym configured for the session, not by splitting on a separator. Covers Claude Code, Hermes, Kilo, OpenClaw, OpenCode and Pi. Hermes and Pi no longer rewrite the names in the response.A resources server that serves its tools over MCP shows its verifier the tool's own name at
/verify, and returns the emitted names in its reply as before.The trajectory file a task folder's verifier reads (
/logs/agent/trajectory.json), and the ATIF export of a saved rollout, use the tool's own name asfunction_name, withmcp_serverandemitted_nameunderextra.nemo_gym.Each tool call of a rollout's trajectory carries
mcp_serverandmcp_toolbesidetool_name, which stays the emitted name.Tool metrics count an MCP tool under its own name. Its span adds
nemo.gym.tool.emitted_nameandnemo.gym.tool.mcp_server.A name that belongs to one of the session's MCP servers but cannot be resolved (the harness may have cut it, or two servers match it) becomes an
mcp_tool_name_unresolvedobservation gap, and/verifyleaves it as emitted.A resources server warns at startup about tools whose name, with the server's, reaches 64 characters, where some harnesses cut the name. A shorter
mcp_server_nameavoids it.An agent declares its naming as
mcp_tool_namingon its class. When a session closes, every tool call the session observed gets its MCP server and tool, including calls a subagent made and calls of earlier activations of a continued session, which no single response lists.Rebuilding a response from an exported trajectory restores the emitted name and the record of its server and tool, so reverification credits a resources server only for its own tools when two servers serve a tool of the same name.
Compatibility
mcp__<server>__<tool>in the trajectory file now sees the tool's own name. The raw name is inextra.nemo_gym.emitted_name.mcp__<grant>__<tool>. A resources server's/verifyscores them the same.nemo.gym.tool.namefor an MCP tool changes from the harness's name to the tool's own name.mcp_tool_name_unresolvedgap is refused by the strict ATIF export, like any rollout with a gap./verifystill stripsmcp__<server>__and accepts<server>__<tool>,<server>_<tool>andmcp_<server>_<tool>when the server serves a tool of that name.Validation
Unit tests: 3,009 passed, 28 skipped, none failed across the repository-wide checks,
tests/unit_tests/trajectory, the new tests and the six adapters' MCP tests.pre-commit runon the changed files passed, including the import-linter contract.Real rollouts, Claude Sonnet 4.6, Docker sandboxes, main at dd09637 against this branch.
Resources server path:
example_single_tool_callwithexpose_tools_over_mcp: truebehindsingle_agent_turn; its verifier gives reward 1 only for a call named exactlyget_weather. Two episodes each.example_single_tool_call__get_weatherexample_single_tool_call_get_weatherexample_single_tool_call_get_weathermcp__example_single_tool_call__get_weatherexample_single_tool_call_get_weather/runmcp__example_single_tool_call__get_weatherThe OpenClaw and Hermes rows are from the head of this branch. The OpenCode, Kilo, Pi and Claude Code rows are from this branch's first two commits (the adapter and
/verifychanges), before the trajectory commits and the review fix; they were not rerun at the head. In the Kilo episode with the tool call, a later model call failed, so its response status isfailedon both trees.Task folder path: a task with one streamable-http MCP server (
hello-tools, toolget_greeting),task_mcp_grants: required, and atests/test.shthat gives reward 1 only if the trajectory file has a call whosefunction_nameis exactlyget_greeting. One episode each.function_nameon mainfunction_nameon this branchhello-tools__get_greetingget_greetingmcp__hello-tools__get_greetingget_greetingmcp__hello-tools__get_greetingget_greetinghello-tools_get_greetingget_greetingNot run: Kilo on the task folder path (the request did not complete on main or on this branch, cause not found), and Claude Code on the task folder path (its sessions take no MCP grants). The unresolved-name gap, the startup warning and the span attributes are covered by unit tests only.
The last commit (reverification, subagent calls, continued sessions) answers the automated review and is covered by unit tests only: a round trip through the export for two servers serving a tool of one name, a session close with subagent and earlier-activation calls, and the shared resolver. No real rollout was run on it.
Known limits
_, a tool of its own named<server>_<something>is taken as that server's tool. A resources server rejects it by its tool list; a task folder has no tool list to check against.