earendil-works/pi · error · Error
Unhandled stop reason: ${_exhaustive}
Error message
Unhandled stop reason: ${_exhaustive} What it means
Error "Unhandled stop reason: ${_exhaustive}" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/api/openai-responses-shared.ts:789
if (incompleteReason === "max_output_tokens") {
return { stopReason: "length" };
}
return {
stopReason: "error",
errorMessage: incompleteReason
? `Response incomplete: ${incompleteReason}`
: "Response incomplete without a provider reason",
};
case "failed":
case "cancelled":
return { stopReason: "error" };
// These two are wonky ...
case "in_progress":
case "queued":
return { stopReason: "stop" };
default: {
const _exhaustive: never = status;
throw new Error(`Unhandled stop reason: ${_exhaustive}`);
}
}
}
View on GitHub (pinned to 4af9d21d3b)
Solutions
- Add handling for the new stop reason in the exhaustive switch.
When it happens
Trigger: Thrown at packages/ai/src/api/openai-responses-shared.ts:789 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/cc42172a4ea01fa1.
Report an issue: GitHub.