From 3652f08e3d4ede0b6f529baf6c6dcce5ecf42b75 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 24 Dec 2025 20:38:23 +0700 Subject: [PATCH] Fix Codex MCP thread item event normalization --- .../server/agent/providers/codex-mcp-agent.ts | 19 ++++++++++++------- plan.md | 7 +++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/server/src/server/agent/providers/codex-mcp-agent.ts b/packages/server/src/server/agent/providers/codex-mcp-agent.ts index f8b9968f8..b4f48f5c8 100644 --- a/packages/server/src/server/agent/providers/codex-mcp-agent.ts +++ b/packages/server/src/server/agent/providers/codex-mcp-agent.ts @@ -910,12 +910,6 @@ class CodexMcpAgentSession implements AgentSession { } private handleMcpEvent(event: unknown): void { - this.emitEvent({ - type: "provider_event", - provider: "codex-mcp", - raw: event, - }); - if (!event || typeof event !== "object") { return; } @@ -933,8 +927,19 @@ class CodexMcpAgentSession implements AgentSession { return; } + const normalizedType = normalizeThreadEventType(type); + const providerRaw = + normalizedType !== type ? { ...eventRecord, type: normalizedType } : eventRecord; + + this.emitEvent({ + type: "provider_event", + provider: "codex-mcp", + raw: providerRaw, + }); + + type = normalizedType; if (type.includes(".") || type.startsWith("turn.") || type.startsWith("thread.") || type.startsWith("item.")) { - this.handleThreadEvent(eventRecord); + this.handleThreadEvent(providerRaw); return; } diff --git a/plan.md b/plan.md index e2b428644..d0bd613b1 100644 --- a/plan.md +++ b/plan.md @@ -265,7 +265,8 @@ Build a new Codex MCP provider side‑by‑side with the existing Codex SDK prov - [x] **Fix**: Codex MCP command output should include exit codes for command tool calls (missing in timeline mapping). - **Done (2025-12-24 20:33)**: Normalized exit code parsing so numeric strings are captured in timeline output. -- [ ] **Fix**: Codex MCP thread/item event mapping for file_change, mcp_tool_call, web_search, and todo_list still failing. +- [x] **Fix**: Codex MCP thread/item event mapping for file_change, mcp_tool_call, web_search, and todo_list still failing. + - **Done (2025-12-24 20:38)**: Normalized MCP provider event payloads to surface item events and thread/item types consistently for timeline mapping. - [ ] **Fix**: Codex MCP should emit error timeline items for failed turns (currently none). @@ -287,9 +288,7 @@ Build a new Codex MCP provider side‑by‑side with the existing Codex SDK prov - Interrupt completes in < 1 second - No zombie processes left running - Session state is clean (can start new session) - - Test BOTH: - - Codex MCP provider interruption - - Codex SDK provider interruption (if applicable) + - Test Codex MCP provider interruption only (SDK is deprecated) - This is critical for user experience - users expect immediate response to cancel - [ ] **Test (E2E)**: Permission flow parity - test both Codex MCP and Claude providers.