earendil-works/pi · error

Google stream ended without a finish reason

Error message

Google stream ended without a finish reason

What it means

Error "Google stream ended without a finish reason" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/api/google-generative-ai.ts:269

						content: currentBlock.text,
						partial: output,
					});
				} else {
					stream.push({
						type: "thinking_end",
						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";

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Retry; inspect the last candidates payload for errors or safety blocks.

When it happens

Trigger: Thrown at packages/ai/src/api/google-generative-ai.ts:269 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/3fb15cdda67aefd4. Report an issue: GitHub.