From 8812107f90d3cd5ae1609699cc139b2819a13101 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 25 Dec 2025 00:04:07 +0700 Subject: [PATCH] Fix codex mcp web_search timeline output --- .../server/agent/providers/codex-mcp-agent.ts | 33 +++++++++++++++++-- plan.md | 3 +- 2 files changed, 33 insertions(+), 3 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 d43ffbddf..32f6a7d0e 100644 --- a/packages/server/src/server/agent/providers/codex-mcp-agent.ts +++ b/packages/server/src/server/agent/providers/codex-mcp-agent.ts @@ -1733,15 +1733,44 @@ class CodexMcpAgentSession implements AgentSession { }); } case "web_search": + { + 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 query = + asString(item.query) ?? + asString(input?.query) ?? + asString((item as { search_query?: unknown }).search_query) ?? + asString((item as { searchQuery?: unknown }).searchQuery); + const results = + outputValue ?? + (item as { results?: unknown }).results ?? + (item as { search_results?: unknown }).search_results ?? + (item as { searchResults?: unknown }).searchResults ?? + (item as { items?: unknown }).items ?? + (item as { documents?: unknown }).documents ?? + (item as { data?: unknown }).data ?? + (item as { content?: unknown }).content ?? + (item as { response?: unknown }).response ?? + (item as { result?: unknown }).result; return createToolCallTimelineItem({ server: "web_search", tool: "web_search", status: (item as { status?: string }).status ?? "completed", callId, - displayName: item.query ? `Web search: ${item.query}` : "Web search", + displayName: query ? `Web search: ${query}` : "Web search", kind: "search", - input: { query: item.query }, + input: input ?? (query ? { query } : undefined), + output: results ?? output, }); + } case "todo_list": return { type: "todo", items: item.items as any }; case "error": diff --git a/plan.md b/plan.md index 84a6bb3c0..d17e8822c 100644 --- a/plan.md +++ b/plan.md @@ -419,9 +419,10 @@ Build a new Codex MCP provider side‑by‑side with the existing Codex SDK prov - Ensure MCP server tool calls surface `server`, `tool`, `input`, and `output` fields. - **Done (2025-12-25 00:00)**: WHAT: added MCP tool identifier/payload extraction helpers and used them for `mcp_tool_call` timeline mapping in `packages/server/src/server/agent/providers/codex-mcp-agent.ts:224` and `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1721`. RESULT: MCP tool call timeline items now normalize server/tool/input/output fields from multiple event shapes. EVIDENCE: Not run (not requested). -- [ ] **Fix**: Codex MCP web_search timeline items should include query input and results output. +- [x] **Fix**: Codex MCP web_search timeline items should include query input and results output. - Ensure web_search tool calls emit a timeline item with query and results. + - **Done (2025-12-25 00:18)**: WHAT: added web_search query/output extraction and result fallback mapping in `packages/server/src/server/agent/providers/codex-mcp-agent.ts:1735`. RESULT: web_search timeline items now include query input and results output when present. EVIDENCE: Not run (not requested). - [ ] **CRITICAL REFACTOR**: Eliminate ALL type casting and defensive coding in Codex MCP provider.