Skip to content

fix(trajectory): export MCP calls the model endpoint returns to ATIF - #6060

Open
ananthsub wants to merge 4 commits into
mainfrom
ananthsub/atif-mcp-call-discriminator
Open

ananthsub wants to merge 4 commits into
mainfrom
ananthsub/atif-mcp-call-discriminator

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

What changed

The Harbor environment server exports each agent transcript to ATIF before it verifies an episode. That export rejected mcp_call items, and the rejection masked the episode as harbor:trajectory_export_failed. The exporter (transcript_to_atif in nemo_gym/trajectory/atif_export.py) now represents them:

  • Each mcp_call exports as an agent step with one tool call. The call keeps its server_label in the call's extra, and so does any status other than completed.
  • When the endpoint ran the tool, its output becomes the step's observation, or its error when there is no output. An error is also kept in the result's extra.
  • A call the endpoint returned without running it has no result, so it is listed in open_tool_calls.
  • A tool call ID may not repeat across mcp_call items and function calls, in either order. The duplicate error now says "tool call", the ATIF term, because either kind of item can raise it.

The NeMoGymResponseMcpCall docstring now describes what the hosted endpoint actually returns.

Why

Harbor runs of terminus_2_sandboxed_agent with gpt-oss-20b masked 9 of 12 episodes this way, with one agent worker and with four.

The items come from the model endpoint. gpt-oss calls its built-in container.exec tool even when the request declares no tools. The NVIDIA-hosted endpoint returns that call as a typed mcp_call with output and error both null, because it did not run the call. A direct request to the endpoint, made outside Gym, returned this item:

{"id": "mcp_90ce2d07847e2efe", "type": "mcp_call", "name": "exec", "server_label": "container",
 "arguments": "{\"cmd\":[\"bash\",\"-lc\",\"git log --oneline --decorate --graph --all\"],\"timeout\": 10000}",
 "approval_request_id": null, "error": null, "output": null, "status": "completed"}

Gym's model server rejects untyped output items, so Gym does not create these items; it passes them through. Terminus 2 reads only message and reasoning text, so it ignores the call and keeps the item in its transcript. The item is model output, and the transcript is also training data, so the fix belongs in the exporter rather than in dropping the item.

The strict rollout exporter (gym_rollout_to_atif) still rejects mcp_call on purpose. That is unchanged.

No issue is linked: the problem showed up while validating #5988, and its Harbor smoke showed the masking with one worker too, so it predates that PR.

Validation

  • tests/unit_tests/trajectory/test_atif_export.py, run in a venv with Harbor installed so that the check against Harbor's own trajectory schema runs instead of skipping. The new cases cover an unrun call followed by a Terminus turn, a call with output, error, or both, a status other than completed, duplicate IDs in every order, and a missing or blank ID or name. They fail against main's exporter and pass here.
  • responses_api_agents/terminus_2_sandboxed_agent/tests/test_observability.py.
  • pre-commit run --files on the changed files.

Rollout evidence

Same command before and after, with Docker sandboxes:

gym eval run terminal_bench_2_1 --agent terminus_2_sandboxed_agent --sandbox docker \
  --model-type openai_model --model nvidia/openai/eccn-gpt-oss-20b \
  --only-tasks fix-git,log-summary-date-ranges,git-multibranch --num-repeats 4 --concurrency 12
  • Before: 9 of 12 episodes masked as harbor:trajectory_export_failed.
  • After: 0 of 12 masked. 8 episodes contained mcp_call items, 89 in all, every one with output and error null.
  • One exported trajectory, rebuilt from an episode with the same call the verifier makes, reads as expected: the step's tool call is exec with its parsed arguments and server_label: container, the next Terminus turn is its observation, and the call ID is in open_tool_calls.

This shows the export works, not grading: every reward was 0, which is the 20B model failing these tasks.

Two things the smoke showed are out of scope here; both are endpoint or parser behavior:

  • Some mcp_call items come from malformed Harmony headers, where the endpoint reads a channel tag such as assistant<|channel|>analysis as the tool name and the model's analysis text as arguments. These export with the raw text kept in raw_arguments, and the trajectory is marked partial with unparsable_arguments.
  • A few episodes logged HTTP 500 and 400 responses from the endpoint. Terminus retried past them, and none masked an episode.

Compatibility

Transcripts that used to fail now export, which changes masking results for gpt-oss runs on hosted endpoints. The transcript export's duplicate-ID error text changes from "function call" to "tool call".

gpt-oss calls its built-in container.exec tool even when the request
declares no tools, and NVIDIA-hosted endpoints return that call as an
mcp_call item without running it. Terminus 2 keeps the model's output
items in its transcript, so the Harbor environment server's ATIF export
met an item it rejected and masked the episode as
harbor:trajectory_export_failed.

The item is the model's own output, so the exporter now represents it:
an agent step with one tool call, the endpoint's output or error as the
step's observation, and a call with neither listed in open_tool_calls.

Signed-off-by: Ananth Subramaniam <[email protected]>
An mcp_call's ID now counts against function call IDs in both orders,
and two answered mcp_calls with one ID are rejected. An error that comes
with output is kept in the result's extra instead of being dropped, and
a status other than completed is kept in the call's extra.

The NeMoGymResponseMcpCall docstring now says what the hosted gpt-oss
endpoint returns: the container.exec call with no output or error,
because the endpoint did not run it.

Signed-off-by: Ananth Subramaniam <[email protected]>
An mcp_call was checked only against function calls still open, so one
reusing the ID of an answered function call exported a second tool call
with that ID. The check now covers every function call ID exported. The
transcript export's duplicate error names a tool call, the ATIF term,
since either kind of item can raise it.

Signed-off-by: Ananth Subramaniam <[email protected]>
@github-actions

github-actions Bot commented Nov 12, 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

LGTM — no concerns found.

I reviewed all three changed files and traced the transcript exporter through Terminus transcript production and Harbor verification. The new mapping preserves endpoint results, errors, status, and unanswered calls; mixed MCP/function ID collisions are checked in both orders. The regression tests assert concrete outcomes, and strict rollout export remains unchanged.

This was static review. I didn't execute tests or independently reproduce the reported smoke 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.

The NeMoGymResponseMcpCall and transcript export docstrings now say what
an mcp_call is and how it is handled, without naming a model or a
hosting provider.

Signed-off-by: Ananth Subramaniam <[email protected]>
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 13, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026

@marcromeyn marcromeyn 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.

The MCP shape from the smoke exports correctly, and the strict exporter still rejects mcp_call. Two paths still mask a gradable episode, as far as I can tell:

  • NeMoGymResponseMcpCall.id is optional, and Terminus passes such items through, but the live exporter raises "MCP calls need an id and a name" when it's missing or blank. Harbor then skips grading. Could it generate a deterministic ID that can't collide with a real one, and mark the conversion partial?
  • Arguments like {"query":"\ud800"} parse as an object, so the call counts as converted, but encoding the trajectory then fails on the unpaired surrogate. Routing values that can't be encoded through the existing raw_arguments / unparsable_arguments fallback would cover it.

Smaller: a test with plain-text MCP arguments, like the Harmony case from the smoke, would pin that raw_arguments survives the metadata merge; the new fixtures all use valid JSON. And the docstrings read null output and error as "the tool never ran". status="in_progress" with both null is accepted too, so "no result returned" is the safer wording.

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:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants