1.5 KiB
1.5 KiB
Codex MCP test hang investigation
Test that appeared stuck
CodexMcpAgentClient (MCP integration) > maps thread/item events for file changes, MCP tools, web search, and todo lists- Wait loop:
packages/server/src/server/agent/providers/codex-mcp-agent.test.ts:577(for await (const event of session.stream(prompt))untilturn_completed/turn_failed)
What was actually happening
- The test was slow (40s+) because the Codex MCP server performed multiple tool call cycles before completing the turn.
- The run ultimately failed (not a true deadlock) because the MCP tool call timeline item never appeared, so
rawItemTypes.has("mcp_tool_call")stayed false.
Root cause
- Codex MCP server emits
mcp_tool_call_beginandmcp_tool_call_endevents with tool invocation + result payloads. codex-mcp-agent.tshandled raw_response_item tool calls but ignoredmcp_tool_call_*events, so MCP tool calls were never mapped to timeline items when those events were the only reliable signal.
Evidence
- Observed event shapes from Codex MCP:
mcp_tool_call_beginwithcall_idandinvocation(server/tool/arguments)mcp_tool_call_endwithresult.Ok.structuredContent
- When mapping those events to tool_call timeline items, the test passed.
Fix
- Add schemas + handlers for
mcp_tool_call_begin/mcp_tool_call_endinpackages/server/src/server/agent/providers/codex-mcp-agent.ts. - Emit
tool_calltimeline items for running/completed MCP tool calls and surface structured tool output.