Fix codex mcp web_search timeline output

This commit is contained in:
Mohamed Boudra
2025-12-25 00:04:07 +07:00
parent 27b0218b94
commit 8812107f90
2 changed files with 33 additions and 3 deletions

View File

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

View File

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