Skip to content

Commit 0f29131

Browse files
committed
fix: handle unsupported Codex dynamic tool output
1 parent c9b732a commit 0f29131

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

extensions/codex/src/app-server/run-attempt.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ describe("runCodexAppServerAttempt", () => {
12391239
contentItems: [
12401240
{ type: "inputText", text: `lookup result: ${rawToolSecret}` },
12411241
{ type: "inputImage", imageUrl: "data:image/png;base64,abc" },
1242+
{ type: "unsupportedCodexOutput", imageUrl: "data:image/png;base64,ignored" },
12421243
],
12431244
});
12441245
const content = result.content as Array<{ text?: string; type?: string; url?: string }>;
@@ -1249,6 +1250,10 @@ describe("runCodexAppServerAttempt", () => {
12491250
expect(content[0]?.text).toContain("lookup result:");
12501251
expect(content[0]?.text).not.toContain(rawToolSecret);
12511252
expect(content[1]).toEqual({ type: "image", url: "data:image/png;base64,abc" });
1253+
expect(content[2]).toEqual({
1254+
type: "text",
1255+
text: "[Unsupported Codex dynamic tool output: unsupportedCodexOutput]",
1256+
});
12521257
expect(JSON.stringify(result)).not.toContain(rawToolSecret);
12531258
});
12541259

extensions/codex/src/app-server/run-attempt.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,19 @@ function toTranscriptToolResultContentItem(item: unknown): Record<string, unknow
331331
if (record.type === "inputText") {
332332
return { type: "text", text: typeof record.text === "string" ? record.text : "" };
333333
}
334-
if (record.type === "inputImage" || typeof record.imageUrl === "string") {
334+
if (record.type === "inputImage") {
335335
return typeof record.imageUrl === "string"
336336
? { type: "image", url: record.imageUrl }
337-
: { type: "text", text: "" };
337+
: { type: "text", text: formatUnsupportedCodexDynamicToolOutput(record.type) };
338338
}
339-
return { type: "text", text: "" };
339+
return { type: "text", text: formatUnsupportedCodexDynamicToolOutput(record.type) };
340+
}
341+
342+
function formatUnsupportedCodexDynamicToolOutput(type: unknown): string {
343+
const rawType = typeof type === "string" ? type.replace(/\s+/g, " ").trim() : "";
344+
const label = rawType ? rawType.slice(0, 80) : "unknown";
345+
const suffix = rawType.length > 80 ? "..." : "";
346+
return `[Unsupported Codex dynamic tool output: ${label}${suffix}]`;
340347
}
341348

342349
type CodexAgentEndHookParams = Parameters<typeof runAgentHarnessAgentEndHook>[0];

0 commit comments

Comments
 (0)