Skip to content

[codex] Emit MCP tool calls as turn items#20677

Merged
pakrym-oai merged 6 commits into
mainfrom
pakrym/mcp-tool-call-turn-item
May 4, 2026
Merged

[codex] Emit MCP tool calls as turn items#20677
pakrym-oai merged 6 commits into
mainfrom
pakrym/mcp-tool-call-turn-item

Conversation

@pakrym-oai
Copy link
Copy Markdown
Collaborator

@pakrym-oai pakrym-oai commented May 1, 2026

Why

McpToolCall was still an app-server item synthesized from deprecated legacy begin/end events. Recent item migrations moved this ownership into core TurnItems, so MCP tool calls now follow the same canonical lifecycle and leave legacy events as compatibility fanout.

Keeping the core item close to the v2 ThreadItem::McpToolCall shape also avoids spreading MCP result semantics across app-server conversion code. Core now owns whether a completed call is completed or failed, and whether the payload is a tool result or an error.

What changed

  • Added core TurnItem::McpToolCall with flattened server, tool, arguments, status, result, and error fields.
  • Updated MCP tool call emitters, including MCP resource tools, to emit ItemStarted/ItemCompleted around directly constructed core MCP items.
  • Updated app-server v2 conversion to project the core MCP item into ThreadItem::McpToolCall without deriving status or splitting Result locally.
  • Ignored live deprecated MCP legacy fanout in app-server v2 to avoid duplicate item notifications, while keeping thread history replay on the legacy event path.

Verification

  • cargo test -p codex-protocol
  • cargo test -p codex-app-server-protocol
  • cargo test -p codex-core --lib mcp_tool_call
  • cargo check -p codex-app-server
  • cargo test -p codex-app-server mcp_tool_call_completion_notification_contains_truncated_large_result

@pakrym-oai pakrym-oai marked this pull request as ready for review May 1, 2026 21:53
@pakrym-oai pakrym-oai requested a review from a team as a code owner May 1, 2026 21:53
@pakrym-oai pakrym-oai merged commit c8c30d9 into main May 4, 2026
36 of 38 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/mcp-tool-call-turn-item branch May 4, 2026 05:50
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants