/** * Types for tool result auto-delegation. * * When large tool results exceed a token threshold, they are automatically * summarized and stored for optional recall. This conserves context tokens * while preserving access to the full data. */ /** * Configuration for tool result delegation. * Controls when and how large tool results are summarized. */ export interface DelegationConfig { /** Whether delegation is enabled. Default: false (opt-in) */ enabled: boolean; /** Token count above which results are delegated. Default: 8000 */ delegationThreshold: number; /** Maximum tokens for the summary. Default: 800 */ summaryMaxTokens: number; /** Milliseconds before stored results expire. Default: 600_000 (10 min) */ resultTTL: number; /** Maximum number of stored results (LRU eviction). Default: 50 */ maxStoredResults: number; /** Summarization strategy. Default: 'auto' */ strategy: 'llm' | 'extractive' | 'auto'; /** Per-tool threshold/strategy overrides */ toolOverrides?: Record; } /** * A stored full result that was replaced by a summary. */ export interface StoredResult { /** Unique delegation ID, e.g., 'dr_1707900000_0' */ id: string; /** Name of the tool that produced the result */ toolName: string; /** Input parameters passed to the tool */ toolInput: Record; /** The full serialized result content */ fullContent: string; /** Token count of the full content */ fullTokens: number; /** The generated summary */ summary: string; /** Token count of the summary */ summaryTokens: number; /** Timestamp when stored */ storedAt: number; /** Timestamp when this result expires */ expiresAt: number; } /** * Events emitted during the delegation lifecycle. */ export type DelegationEvent = { type: 'delegation:started'; toolName: string; originalTokens: number; delegationId: string; } | { type: 'delegation:completed'; toolName: string; originalTokens: number; summaryTokens: number; delegationId: string; strategy: 'llm' | 'extractive'; } | { type: 'delegation:failed'; toolName: string; error: string; } | { type: 'delegation:recall'; delegationId: string; found: boolean; }; /** * Default delegation configuration values. */ export declare const DEFAULT_DELEGATION_CONFIG: DelegationConfig;