/** * Summarization-based conversation history management. * * This module provides a conversation manager that summarizes older messages * when the context window overflows, preserving important information rather * than simply discarding it. */ import { ConversationManager, type ProactiveCompressionConfig, type ConversationManagerReduceOptions } from './conversation-manager.js'; import type { Model } from '../models/model.js'; /** * Configuration for the summarization conversation manager. */ export type SummarizingConversationManagerConfig = { /** * Model to use for generating summaries. When provided, overrides the model * attached to the agent. Useful when you want to use a different model than * the one attached to the agent. */ model?: Model; /** * Ratio of messages to summarize when context overflow occurs. * Value is clamped to [0.1, 0.8]. Defaults to 0.3 (summarize 30% of oldest messages). */ summaryRatio?: number; /** * Minimum number of recent messages to always keep. * Defaults to 10. */ preserveRecentMessages?: number; /** * Custom system prompt for summarization. If not provided, uses a default * prompt that produces structured bullet-point summaries. */ summarizationSystemPrompt?: string; /** * Enable proactive context compression before the model call. * * - `true`: compress when 70% of the context window is used (default threshold). * - `{ compressionThreshold: number }`: compress at the specified ratio (0, 1]. * - `false` or omitted: disabled, only reactive overflow recovery is used. */ proactiveCompression?: boolean | ProactiveCompressionConfig; /** * Number of messages at the start of the conversation to permanently pin. * Pinned messages are protected from summarization and compacted to the front. */ pinFirst?: number; }; /** * Implements a summarization strategy for managing conversation history. * * When a {@link ContextWindowOverflowError} occurs, this manager summarizes * the oldest messages using a model call and replaces them with a single * summary message, preserving context that would otherwise be lost. */ export declare class SummarizingConversationManager extends ConversationManager { readonly name = "strands:summarizing-conversation-manager"; private readonly _model; private readonly _summaryRatio; private readonly _preserveRecentMessages; private readonly _summarizationSystemPrompt; private readonly _pinFirst; private _pinFirstApplied; constructor(config?: SummarizingConversationManagerConfig); /** * Reduce the conversation history by summarizing older messages. * * When `error` is set (reactive overflow recovery), summarization failure is rethrown * with the original error as cause — the agent loop must not proceed with an overflow. * * When `error` is undefined (proactive compression), summarization failure is logged * and returns `false` — the model call proceeds regardless. * * @param options - The reduction options * @returns `true` if the history was reduced, `false` otherwise */ reduce({ agent, model, error }: ConversationManagerReduceOptions): Promise; /** * Summarize the oldest messages and replace them with a summary. * * @param agent - The agent instance * @param model - The model to use for summarization * @returns `true` if the history was reduced, `false` otherwise */ private _summarizeOldest; } //# sourceMappingURL=summarizing-conversation-manager.d.ts.map