Skip to content

[#31]: handle mcp_tool_call turn items from Codex v0.129.0#39

Open
delexw wants to merge 1 commit intomainfrom
fix-issue-31
Open

[#31]: handle mcp_tool_call turn items from Codex v0.129.0#39
delexw wants to merge 1 commit intomainfrom
fix-issue-31

Conversation

@delexw
Copy link
Copy Markdown
Contributor

@delexw delexw commented May 10, 2026

Summary

Fixes #31

Codex v0.129.0 (PR #20677) introduced mcp_tool_call and mcp_tool_call_output as first-class response_item turn entries. Previously these new payload types fell through the _ => {} fallback in handle_response_item and were silently discarded, so MCP tool calls from v0.129.0+ sessions would vanish from the parsed turn output.

Changes

src-tauri/src/parser/turn.rs

  • Added "mcp_tool_call" handler in handle_response_item: reads server + tool fields (falling back to namespace/name for forward compatibility), reconstructs an mcp__<server> namespace, and registers the call via the existing add_function_call path so it is classified as ToolKind::McpTool. Arguments are accepted as either a JSON object or a pre-stringified string.
  • Added "mcp_tool_call_output" handler: finalises the pending call via add_function_call_output, supporting both content-array [{"type":"text","text":"..."}] and plain-string output shapes.

No new types, structs, or public API changes — the fix wires the new JSONL item types into the existing ToolCallBuilder infrastructure.

Tests

Four new tests in parser::turn::tests:

Test Covers
mcp_tool_call_turn_items_classified_as_mcp_tool Content-array output; verifies kind, mcp_server, mcp_tool, output, status
mcp_tool_call_turn_items_with_string_output Plain-string output path
mcp_tool_call_turn_items_with_stringified_arguments Arguments arriving as a JSON string instead of an object
unknown_response_item_types_are_silently_skipped Future unknown item types do not cause panics or bogus tool calls

Verification

cargo test --lib  →  63 passed, 0 failed
npx vitest run    → 122 passed, 0 failed
cargo clippy      →  0 warnings
npx oxlint        →  0 warnings / errors
npx oxfmt --check →  all files correctly formatted
npx tsc --noEmit  →  no type errors

Codex v0.129.0 (PR #20677) introduced mcp_tool_call and
mcp_tool_call_output as first-class response_item turn entries.
Previously these fell through the _ => {} fallback in
handle_response_item and were silently discarded.

Add explicit handlers that wire both new types into the existing
ToolCallBuilder paths:
- mcp_tool_call: registered via add_function_call with a reconstructed
  mcp__<server> namespace so the call is classified as McpTool
- mcp_tool_call_output: finalised via add_function_call_output;
  supports both content-array and plain-string output shapes

Arguments may arrive as a JSON object or pre-stringified string;
both forms are handled.

Adds four tests covering: content-array output, plain-string output,
stringified arguments, and graceful skipping of unknown future item types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compat] Codex v0.129.0: MCP tool calls now emitted as turn items

1 participant