fix(codex): use aggregated_output for structured command results

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 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2025-11-28 19:46:55 +00:00
parent 4001b7dc0a
commit bf04b7d5df

View File

@@ -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,
});
}