/** * LlmSummarizationEngine — default ContextEngine backed by an LLM. * * Implements the Hermes §7.6 SUMMARY_PREFIX compression pattern: * 1. Keep the first {@link KEEP_FIRST} messages verbatim (system context). * 2. Keep the last {@link KEEP_LAST} messages verbatim (recent context). * 3. Summarize the middle window via a single {@link LlmExecutor.auxiliary} call * using the `'compression'` role (cheap haiku-class model). * * Threshold: compress when `promptTokens / contextBudget >= 0.75`. * * @module memory/context-engines/llm-summarizer * @task T9304 * @epic T9261 T-LLM-CRED-CENTRALIZATION * @see packages/contracts/src/memory/context-engine.ts */ import type { TransportMessage } from '@cleocode/contracts/llm/normalized-response.js'; import type { CompressedContext, ContextEngine } from '@cleocode/contracts/memory/context-engine.js'; /** Minimum estimated tokens before compression is even attempted. */ export declare const MIN_SUMMARY_TOKENS = 2000; /** Compression threshold ratio — compress when prompt fills >= 75% of budget. */ export declare const SUMMARY_RATIO = 0.2; /** Upper bound on summary output tokens to keep the compressed history small. */ export declare const SUMMARY_TOKENS_CEILING = 12000; /** * Default {@link ContextEngine} implementation using LLM-backed summarization. * * Uses the `'compression'` role (resolved via `getLlmExecutor('compression')`) * so the provider + model + credential come from `config.llm.roles.compression` * → `config.llm.default` → `config.llm.daemon` → implicit haiku fallback. * * @example * ```ts * const engine = new LlmSummarizationEngine(); * const factory = new DefaultLlmExecutorFactory({ contextEngine: engine }); * const executor = await factory.createForRole('orchestrator'); * ``` */ export declare class LlmSummarizationEngine implements ContextEngine { /** * Returns `true` when the prompt is large enough to warrant compression. * * Compression triggers when BOTH conditions hold: * - `promptTokens >= MIN_SUMMARY_TOKENS` * - `promptTokens / contextBudget >= 0.75` * * @param promptTokens - Estimated token count of the current session history. * @param contextBudget - Effective context-window budget for the bound model. */ shouldCompress(promptTokens: number, contextBudget: number): boolean; /** * Compresses the session history using LLM summarization. * * Preserves the first {@link KEEP_FIRST} and last {@link KEEP_LAST} messages * verbatim. The middle window is summarized via an auxiliary LLM call with the * {@link SUMMARY_PREFIX} header, producing a single synthetic `assistant` * message that replaces the middle turns. * * @param messages - Current read-only conversation history snapshot. * @param focusTopic - Optional topic hint appended to the summarization prompt. * @returns The compressed context with before/after token estimates. */ compress(messages: readonly TransportMessage[], focusTopic?: string): Promise; } //# sourceMappingURL=llm-summarizer.d.ts.map