{"record":{"id":"3fa80cffde50fd5e","repo":"openai/codex","slug":"failed-to-parse-item-item","errorCode":null,"errorMessage":"Failed to parse item: ${item}","messagePattern":"Failed to parse item: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"sdk/typescript/src/thread.ts","lineNumber":103,"sourceCode":"      sandboxMode: options?.sandboxMode,\n      workingDirectory: options?.workingDirectory,\n      skipGitRepoCheck: options?.skipGitRepoCheck,\n      outputSchemaFile: schemaPath,\n      modelReasoningEffort: options?.modelReasoningEffort,\n      signal: turnOptions.signal,\n      networkAccessEnabled: options?.networkAccessEnabled,\n      webSearchMode: options?.webSearchMode,\n      webSearchEnabled: options?.webSearchEnabled,\n      approvalPolicy: options?.approvalPolicy,\n      additionalDirectories: options?.additionalDirectories,\n    });\n    try {\n      for await (const item of generator) {\n        let parsed: ThreadEvent;\n        try {\n          parsed = JSON.parse(item) as ThreadEvent;\n        } catch (error) {\n          throw new Error(`Failed to parse item: ${item}`, { cause: error });\n        }\n        if (parsed.type === \"thread.started\") {\n          this._id = parsed.thread_id;\n        } else if (parsed.type === \"turn.completed\") {\n          parsed.usage.cache_write_input_tokens ??= 0;\n        }\n        yield parsed;\n      }\n    } finally {\n      await cleanup();\n    }\n  }\n\n  /** Provides the input to the agent and returns the completed turn. */\n  async run(input: Input, turnOptions: TurnOptions = {}): Promise<Turn> {\n    const generator = this.runStreamedInternal(input, turnOptions);\n    const items: ThreadItem[] = [];\n    let finalResponse: string = \"\";","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/sdk/typescript/src/thread.ts#L85-L121","documentation":"Error \"Failed to parse item: ${item}\" thrown in openai/codex.","triggerScenarios":"Thrown at sdk/typescript/src/thread.ts:103 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the stream item against the current schema and update the SDK if the runtime item format changed."],"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"}