Skip to content

fix(agent): report simple_agent session tool calls as observations - #4993

Draft
yaoyu-33 wants to merge 1 commit into
mainfrom
fix/simple-agent-session-tool-records
Draft

yaoyu-33 wants to merge 1 commit into
mainfrom
fix/simple-agent-session-tool-records

Conversation

@yaoyu-33

Copy link
Copy Markdown
Contributor

What changed and why

With model-call capture on, a simple_agent episode run through an Environment Server (environment_servers/single_agent_turn, single_agent_turn_legacy) lost its executed tool records. The same episode under /run reports them with status and timing.

Why: a session caller sends the activation index, so the turn reply carries no trajectory. The session kept only trajectory.invocations and trajectory.gaps in state.observations. Close then returned agent_observations with no tool records. So the collected ng_trajectory.tool_calls came back empty and ng_perf.num_tool_calls was 0.

Fix (responses_api_agents/simple_agent/app.py): each activation now also adds a ToolCallObservation for every executed tool call to the session's AgentObservationBundle. This uses the existing observation contract. _build_trajectory_record in nemo_gym/rollout_collection.py already merges ToolCallObservation records into ng_trajectory.tool_calls and rejoins each call's output from the invocation conversation, so the records drop output. Checkpoint export already carries the session's observations, so a restored session keeps its tool records too.

This affects every config that #4953 moves from the legacy_agent relay to single_agent_turn_legacy. The data loss is opt-in, since capture is off by default, but it happens silently. This PR is independent of that stack and is based on main.

Issue: none filed. This was found while reviewing #4953.

Validation

  • New test test_a_session_reports_the_tools_the_agent_executed_as_run_does (environment_servers/single_agent_turn/tests/test_app.py). It runs the same tool-calling simple_agent episode, with capture on, through /run and through SingleAgentTurnEnvironmentServer plus the legacy flat adapter, using a real agent app over ASGI. It then collects both results with _attach_trajectory_record / _build_ng_perf. It asserts that both give the tool record ("root", "lookup", "completed", "42") and num_tool_calls == 1. With the fix reverted, the session path gives ([], 0).
  • Updated test_agent_session_uses_seeded_direct_http_tool_access[True] in responses_api_agents/simple_agent/tests/test_app.py. It used to assert the session close carried only the invocation, which was the bug. It now also expects the tool_call observation (name, status, no output).
  • pytest environment_servers/single_agent_turn/tests: 106 passed
  • pytest environment_servers/single_agent_turn_legacy/tests: 18 passed
  • pytest responses_api_agents/simple_agent/tests: 77 passed
  • pytest tests/unit_tests/test_rollout_collection.py tests/unit_tests/test_checkpoint_agent.py tests/unit_tests/test_harness_conformance_ci.py: 91 passed, 1 skipped
  • pre-commit run --files <changed files>: passed

Rollout evidence

N/A. This changes observability metadata only: which agent observation records a session returns at close. It does not change agent, tool, or verifier behavior or the reward. The end-to-end test above exercises the real simple_agent app through the Environment Server.

Compatibility

When capture is on, ng_agent_observations.records from a simple_agent session now includes tool_call records. When capture is off, nothing changes.

🤖 Generated with Claude Code

With model-call capture on, a simple_agent episode run through an
Environment Server (single_agent_turn, single_agent_turn_legacy) lost
its executed tool records: the session kept only the trajectory's
invocations and gaps, so the collected ng_trajectory had no tool_calls
and ng_perf.num_tool_calls was 0, while /run reported them.

The session now adds a ToolCallObservation for each executed tool call
to the agent observations it returns at close. Rollout collection
already merges these into ng_trajectory.tool_calls and rejoins each
call's output from the invocation conversation.

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

copy-pr-bot Bot commented Oct 23, 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

Copy link
Copy Markdown
Contributor Author

/ok to test 2ef4896

This branch was previously deployed

1 inactive deployment
public — 2ef4896a Deployed Oct 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #6855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants