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:
@@ -818,11 +818,23 @@ class CodexAgentSession implements AgentSession {
|
|||||||
case "reasoning":
|
case "reasoning":
|
||||||
return { type: "reasoning", text: item.text };
|
return { type: "reasoning", text: item.text };
|
||||||
case "command_execution": {
|
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 cwd = (item as any)?.cwd;
|
||||||
const commandValue = item.command;
|
const commandValue = item.command;
|
||||||
const command = typeof commandValue === "string" ? commandValue :
|
const command = typeof commandValue === "string" ? commandValue :
|
||||||
Array.isArray(commandValue) ? (commandValue as string[]).join(" ") : "command";
|
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({
|
return createToolCallTimelineItem({
|
||||||
server: "command",
|
server: "command",
|
||||||
tool: "shell",
|
tool: "shell",
|
||||||
@@ -831,12 +843,7 @@ class CodexAgentSession implements AgentSession {
|
|||||||
displayName: buildCommandDisplayName(item.command),
|
displayName: buildCommandDisplayName(item.command),
|
||||||
kind: "execute",
|
kind: "execute",
|
||||||
input: { command: item.command, cwd },
|
input: { command: item.command, cwd },
|
||||||
output: typeof output === "string" ? {
|
output: structuredOutput,
|
||||||
type: "command",
|
|
||||||
command,
|
|
||||||
output,
|
|
||||||
cwd,
|
|
||||||
} : undefined,
|
|
||||||
error: (item as any)?.error,
|
error: (item as any)?.error,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user