{"record":{"id":"059963046b457f17","repo":"earendil-works/pi","slug":"codex-stream-ended-without-a-stop-reason","errorCode":null,"errorMessage":"Codex stream ended without a stop reason","messagePattern":"Codex stream ended without a stop reason","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/openai-codex-responses.ts","lineNumber":105,"sourceCode":"\tprevious_response_id?: string;\n\tinput?: ResponseInput;\n\ttools?: OpenAITool[];\n\ttool_choice?: OpenAICodexResponsesOptions[\"toolChoice\"];\n\tparallel_tool_calls?: boolean;\n\ttemperature?: number;\n\treasoning?: { effort?: string; summary?: string };\n\tservice_tier?: ResponseCreateParamsStreaming[\"service_tier\"];\n\ttext?: { verbosity?: string };\n\tinclude?: string[];\n\tprompt_cache_key?: string;\n\t[key: string]: unknown;\n}\n\ntype SuccessfulAssistantMessage = AssistantMessage & { stopReason: \"stop\" | \"length\" | \"toolUse\" };\n\nfunction assertSuccessfulOutput(output: AssistantMessage): asserts output is SuccessfulAssistantMessage {\n\tif (output.stopReason === \"pending\") {\n\t\tthrow new Error(\"Codex stream ended without a stop reason\");\n\t}\n\tif (output.stopReason === \"error\" || output.stopReason === \"aborted\") {\n\t\tthrow new Error(output.errorMessage || \"An unknown error occurred\");\n\t}\n}\n\n// ============================================================================\n// Retry Helpers\n// ============================================================================\n\nfunction isTerminalRateLimitError(errorText: string): boolean {\n\treturn /GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(\n\t\terrorText,\n\t);\n}\n\nfunction isRetryableError(status: number, errorText: string): boolean {\n\tif (status === 429 && isTerminalRateLimitError(errorText)) {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/openai-codex-responses.ts#L87-L123","documentation":"Error \"Codex stream ended without a stop reason\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/openai-codex-responses.ts:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry; inspect the terminal stream events for an error payload."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}