From 4ef376632836eef0e25fa743a2e67036f1713304 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 24 Dec 2025 23:53:20 +0700 Subject: [PATCH] Emit read_file timeline items for Codex MCP --- .../server/agent/providers/codex-mcp-agent.ts | 38 +++++++++++++++++++ plan.md | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) 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 9d35b41c6..98e9ff413 100644 --- a/packages/server/src/server/agent/providers/codex-mcp-agent.ts +++ b/packages/server/src/server/agent/providers/codex-mcp-agent.ts @@ -1138,6 +1138,8 @@ class CodexMcpAgentSession implements AgentSession { const isTopLevelItemEvent = type === "file_change" || + type === "read_file" || + type === "file_read" || type === "mcp_tool_call" || type === "web_search" || type === "todo_list"; @@ -1613,6 +1615,42 @@ class CodexMcpAgentSession implements AgentSession { output: { files }, }); } + case "read_file": + case "file_read": { + const inputValue = (item as { input?: unknown }).input; + const outputValue = (item as { output?: unknown }).output; + const input = + inputValue && typeof inputValue === "object" + ? (inputValue as Record) + : undefined; + const output = + outputValue && typeof outputValue === "object" + ? (outputValue as Record) + : undefined; + const path = + asString(input?.path) ?? + asString(input?.file_path) ?? + asString(input?.filePath) ?? + asString(item.path) ?? + asString(item.file_path) ?? + asString(item.filePath); + const content = + typeof outputValue === "string" + ? outputValue + : asString(output?.content) ?? + asString(item.content) ?? + asString(item.text); + return createToolCallTimelineItem({ + server: "file_read", + tool: "read_file", + status: (item as { status?: string }).status ?? "completed", + callId, + displayName: path ? `Read ${path}` : "Read file", + kind: "read", + input: input ?? (path ? { path } : undefined), + output: content ?? output ?? outputValue, + }); + } case "mcp_tool_call": return createToolCallTimelineItem({ server: item.server as string, diff --git a/plan.md b/plan.md index c07b0c509..fd53c7708 100644 --- a/plan.md +++ b/plan.md @@ -408,10 +408,11 @@ Build a new Codex MCP provider side‑by‑side with the existing Codex SDK prov - Align with `REPORT-codex-mcp-tool-call-coverage.md`. - **Done (2025-12-24 23:50)**: WHAT: normalized apply_patch change payloads, cached per-call patch metadata, and emitted file_change outputs with path/kind plus before/after/patch content in `packages/server/src/server/agent/providers/codex-mcp-agent.ts:150`, `packages/server/src/server/agent/providers/codex-mcp-agent.ts:459`, `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1335`, and `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1593`. RESULT: patch_apply tool_call timeline output now includes file metadata and change content needed for before/after validation. EVIDENCE: Not run (not requested). -- [ ] **Fix**: Codex MCP should emit read_file tool_call timeline items with input/output content. +- [x] **Fix**: Codex MCP should emit read_file tool_call timeline items with input/output content. - Map Codex MCP read_file events into timeline items (tool name, file path, content snippet). - Ensure the E2E coverage test can find `tool: "read_file"` with content. + - **Done (2025-12-24 23:52)**: WHAT: normalized top-level `read_file`/`file_read` events into thread items and mapped read file tool calls with path/content input/output in `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1139` and `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1618`. RESULT: read_file tool calls now emit timeline items with tool name, file path input, and content output for Codex MCP. EVIDENCE: Not run (not requested). - [ ] **Fix**: Codex MCP should emit external MCP tool calls (mcp_tool_call) with input/output in timeline items.