import type { AssistantMessage } from "../types.ts"; /** Returns OpenRouter's `native_finish_reason` from a streamed chat completion choice, when present. */ export declare function readOpenRouterNativeFinishReason(choice: object): string | undefined; /** * Records a native finish reason that differs from `finishReason` on a message whose stop reason was * already mapped from `finishReason`: `rawStopReason` becomes e.g. "stop.MALFORMED_RESPONSE" (the * format of openai-responses' "incomplete.max_output_tokens"), and an error message gets the native * reason appended. The stop reason itself is unchanged. */ export declare function applyOpenRouterNativeFinishReason(message: AssistantMessage, finishReason: string, nativeReason: string): void; /** * Turns an OpenRouter `stop` that is really an upstream failure into a retryable error. * * OpenRouter reports any upstream finish reason it has no failure case for as `finish_reason: "stop"`, * so some upstream failures arrive as `stop` and only `native_finish_reason` still names them. * Without this, pi would end such a turn silently, often with nothing but a thinking block. Example as * of November 2026: Gemini's transient MALFORMED_RESPONSE after streamed reasoning arrives as `stop` * (OpenRouter already reports it as `finish_reason: "error"` when there is no output at all). * * A legitimately empty turn also arrives as `stop`, e.g. Claude ending with an empty `end_turn` after a * tool result, and should still end quietly. Only the native reason tells the two apart: a turn without * visible output (text or tool calls; reasoning does not count) is flagged unless its native reason is * a clean stop. The message matches the retry pattern for OpenRouter's own "Provider returned an * empty response". */ export declare function flagOpenRouterEmptyStop(message: AssistantMessage, nativeReason: string): void; //# sourceMappingURL=openrouter-finish-reason.d.ts.map