Emit read_file timeline items for Codex MCP

This commit is contained in:
Mohamed Boudra
2025-12-24 23:53:20 +07:00
parent 672261872a
commit 4ef3766328
2 changed files with 40 additions and 1 deletions

View File

@@ -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<string, unknown>)
: undefined;
const output =
outputValue && typeof outputValue === "object"
? (outputValue as Record<string, unknown>)
: 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,

View File

@@ -408,10 +408,11 @@ Build a new Codex MCP provider sidebyside 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.