earendil-works/pi · error
Provider stopped with
Error message
Provider stopped with: ${output.rawStopReason} What it means
When Google reports finishReason STOP-abnormal values mapped to 'aborted' or 'error' (safety block, recitation, provisioning failure), the raw reason is embedded in the thrown message; if no raw reason exists, it degrades to 'An unknown error occurred'. The turn failed server-side.
Solutions
- Handle the raw stop reason in the message (for example SAFETY or MAX_TOKENS); adjust the prompt or limits.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/ai/src/api/google-generative-ai.ts:275 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/00b949135ba7ebc7.
Report an issue: GitHub.
Appendix: source
Thrown at packages/ai/src/api/google-generative-ai.ts:275
contentIndex: blockIndex(),
content: currentBlock.thinking,
partial: output,
});
}
}
if (options?.signal?.aborted) {
throw new Error("Request was aborted");
}
if (output.stopReason === "pending") {
throw new Error("Google stream ended without a finish reason");
}
if (output.stopReason === "aborted" || output.stopReason === "error") {
const errorMessage = output.rawStopReason
? `Provider stopped with: ${output.rawStopReason}`
: "An unknown error occurred";
throw new Error(errorMessage);
}
stream.push({ type: "done", reason: output.stopReason, message: output });
stream.end();
} catch (error) {
// Remove internal index property used during streaming
for (const block of output.content) {
if ("index" in block) {
delete (block as { index?: number }).index;
}
}
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
output.errorMessage = formatProviderError(normalizeProviderError(error));
stream.push({ type: "error", reason: output.stopReason, error: output });
stream.end();
}
})();
View on GitHub (pinned to 4af9d21d3b)