openai/codex · error · Error
${turnFailure.message}
Error message
${turnFailure.message} What it means
Error "${turnFailure.message}" thrown in openai/codex.
Source
Thrown at sdk/typescript/src/thread.ts:138
const items: ThreadItem[] = [];
let finalResponse: string = "";
let usage: Usage | null = null;
let turnFailure: ThreadError | null = null;
for await (const event of generator) {
if (event.type === "item.completed") {
if (event.item.type === "agent_message") {
finalResponse = event.item.text;
}
items.push(event.item);
} else if (event.type === "turn.completed") {
usage = event.usage;
} else if (event.type === "turn.failed") {
turnFailure = event.error;
break;
}
}
if (turnFailure) {
throw new Error(turnFailure.message);
}
return { items, finalResponse, usage };
}
}
function normalizeInput(input: Input): { prompt: string; images: string[] } {
if (typeof input === "string") {
return { prompt: input, images: [] };
}
const promptParts: string[] = [];
const images: string[] = [];
for (const item of input) {
if (item.type === "text") {
promptParts.push(item.text);
} else if (item.type === "local_image") {
images.push(item.path);
}
}View on GitHub (pinned to 339751715c)
Solutions
- Inspect the nested turn failure message, fix the reported cause, and retry the turn.
When it happens
Trigger: Thrown at sdk/typescript/src/thread.ts:138 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/eff46be8ae906e17.
Report an issue: GitHub.