From bf04b7d5dfab06594033ede6e342f0660cef9665 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 28 Nov 2025 19:46:55 +0000 Subject: [PATCH] fix(codex): use aggregated_output for structured command results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex SDK uses aggregated_output and exit_code fields for command execution results (not output). Build structured output matching StructuredToolResult type so frontend renders Codex commands the same way as Claude commands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/server/agent/providers/codex-agent.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/server/src/server/agent/providers/codex-agent.ts b/packages/server/src/server/agent/providers/codex-agent.ts index 5f2a1392c..719898eb0 100644 --- a/packages/server/src/server/agent/providers/codex-agent.ts +++ b/packages/server/src/server/agent/providers/codex-agent.ts @@ -818,11 +818,23 @@ class CodexAgentSession implements AgentSession { case "reasoning": return { type: "reasoning", text: item.text }; case "command_execution": { - const output = (item as any)?.output; + // Codex SDK uses aggregated_output and exit_code + const aggregatedOutput = (item as any)?.aggregated_output; + const exitCode = (item as any)?.exit_code; const cwd = (item as any)?.cwd; const commandValue = item.command; const command = typeof commandValue === "string" ? commandValue : Array.isArray(commandValue) ? (commandValue as string[]).join(" ") : "command"; + + // Build structured command result matching StructuredToolResult type + const structuredOutput = typeof aggregatedOutput === "string" ? { + type: "command" as const, + command, + output: aggregatedOutput, + exitCode: typeof exitCode === "number" ? exitCode : undefined, + cwd, + } : undefined; + return createToolCallTimelineItem({ server: "command", tool: "shell", @@ -831,12 +843,7 @@ class CodexAgentSession implements AgentSession { displayName: buildCommandDisplayName(item.command), kind: "execute", input: { command: item.command, cwd }, - output: typeof output === "string" ? { - type: "command", - command, - output, - cwd, - } : undefined, + output: structuredOutput, error: (item as any)?.error, }); }