{"record":{"id":"eff46be8ae906e17","repo":"openai/codex","slug":"turnfailure-message","errorCode":null,"errorMessage":"${turnFailure.message}","messagePattern":"\\$\\{turnFailure\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"sdk/typescript/src/thread.ts","lineNumber":138,"sourceCode":"    const items: ThreadItem[] = [];\n    let finalResponse: string = \"\";\n    let usage: Usage | null = null;\n    let turnFailure: ThreadError | null = null;\n    for await (const event of generator) {\n      if (event.type === \"item.completed\") {\n        if (event.item.type === \"agent_message\") {\n          finalResponse = event.item.text;\n        }\n        items.push(event.item);\n      } else if (event.type === \"turn.completed\") {\n        usage = event.usage;\n      } else if (event.type === \"turn.failed\") {\n        turnFailure = event.error;\n        break;\n      }\n    }\n    if (turnFailure) {\n      throw new Error(turnFailure.message);\n    }\n    return { items, finalResponse, usage };\n  }\n}\n\nfunction normalizeInput(input: Input): { prompt: string; images: string[] } {\n  if (typeof input === \"string\") {\n    return { prompt: input, images: [] };\n  }\n  const promptParts: string[] = [];\n  const images: string[] = [];\n  for (const item of input) {\n    if (item.type === \"text\") {\n      promptParts.push(item.text);\n    } else if (item.type === \"local_image\") {\n      images.push(item.path);\n    }\n  }","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/sdk/typescript/src/thread.ts#L120-L156","documentation":"Error \"${turnFailure.message}\" thrown in openai/codex.","triggerScenarios":"Thrown at sdk/typescript/src/thread.ts:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the nested turn failure message, fix the reported cause, and retry the turn."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}