earendil-works/pi · error · Error
${model.provider} stream ended without a terminal event
Error message
${model.provider} stream ended without a terminal event What it means
Error "${model.provider} stream ended without a terminal event" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/api/pi-messages.ts:412
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
if (!response.ok) {
const body = await response.text();
throw createPiMessagesResponseError(model, url, response, body);
}
if (!response.body) {
throw new Error(`${model.provider} response has no body`);
}
for await (const piEvent of readPiMessagesEvents(response.body)) {
const event = convertEvent(piEvent);
eventStream.push(event);
if (event.type === "done" || event.type === "error") {
return;
}
}
throw new Error(`${model.provider} stream ended without a terminal event`);
} catch (error) {
eventStream.push(createErrorEvent(model, error, options?.signal?.aborted ?? false));
}
})();
return eventStream;
};
export const streamSimple: StreamFunction<"pi-messages", SimpleStreamOptions> = (
model: Model<"pi-messages">,
context: Context,
options?: SimpleStreamOptions,
): AssistantMessageEventStream => {
const extra = options as PiMessagesOptions | undefined;
return stream(model, context, {
...options,
reasoning: options?.reasoning,
toolChoice: options?.toolChoice,View on GitHub (pinned to 4af9d21d3b)
Solutions
- Retry; check for stream truncation before the terminal event.
When it happens
Trigger: Thrown at packages/ai/src/api/pi-messages.ts:412 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/c811eec79d5cda07.
Report an issue: GitHub.