import type { Message } from "@earendil-works/pi-ai";
/**
 * Normalizes a summarization request's final message list so strict
 * turn-alternation providers (Gemini) accept it. Gemini rejects a functionCall
 * model turn that follows another model turn, and rejects any conversation
 * whose first turn is not a user turn — both shapes occur in real
 * summarization inputs:
 *
 * - sessions contain adjacent assistant messages (split turns, retries), and
 * - budget pruning / overflow shrinking can drop the leading user message.
 *
 * This runs on the converted LLM message list (after convertToLlm, where
 * context-excluded entries are already dropped and roles are final), and the
 * caller re-runs pair repair on the result so the leading drop cannot leave an
 * orphaned toolResult behind. Two repairs, in order:
 *
 * 1. Adjacent assistant messages are merged into one (content concatenated).
 *    Messages with stopReason error/aborted are left alone: downstream
 *    provider transforms drop them, which heals the ordering on its own, and
 *    merging would replay partial content those transforms intentionally
 *    discard. The merged message keeps the first message's metadata
 *    (stopReason, usage): these messages are outbound request payloads only,
 *    where usage is never read and stopReason is consumed solely as the
 *    error/aborted drop filter this merge already excludes.
 * 2. Everything before the first user message is dropped. Budget pruning has
 *    already judged the oldest content expendable; a leading assistant /
 *    toolResult fragment would only produce a provider rejection. The list
 *    passes through unchanged when no user message exists, and when the only
 *    user message is the trailing summarization instruction itself — dropping
 *    there would summarize nothing, so both paths are defensive only.
 */
export declare function normalizeSummarizationTurnOrder(messages: Message[]): Message[];
//# sourceMappingURL=summarization-turn-order.d.ts.map