import type { PruneCalibrationState } from '@/types/graph'; /** * Creates an initial pruning calibration state. * * @param initialRatio - Starting calibration ratio (default: 1.0) * @returns Fresh calibration state */ export declare function createPruneCalibration(initialRatio?: number): PruneCalibrationState; /** * Updates the pruning calibration using Exponential Moving Average (EMA). * * Problem: Without calibration, the pruner's token estimates can diverge from * reality across iterations, causing either: * - Over-pruning (context cliff): Too many messages removed at once, losing critical tool results * - Under-pruning: Not enough messages removed, hitting hard token limits * * Solution: Track the ratio between actual token usage (from API response) and * estimated token usage (from our token counter). Apply EMA smoothing so the * calibration adjusts gradually, preventing oscillation. * * The calibration ratio is applied to maxTokens in the pruner: * effectiveMaxTokens = maxTokens * calibrationRatio * * If actual > estimated → ratio decreases → prune more aggressively * If actual < estimated → ratio increases → prune less aggressively * * @param state - Current calibration state * @param actualTokens - Actual token count from API response (UsageMetadata) * @param estimatedTokens - Estimated token count from token counter * @param alpha - EMA smoothing factor (default: PRUNING_EMA_ALPHA) * @returns Updated calibration state (new object, does not mutate input) */ export declare function updatePruneCalibration(state: PruneCalibrationState, actualTokens: number, estimatedTokens: number, alpha?: number): PruneCalibrationState; /** * Applies the calibration ratio to a max token budget. * The ratio adjusts the effective budget so pruning is more or less aggressive * based on observed vs. estimated token divergence. * * @param maxTokens - Raw max token budget * @param state - Current calibration state * @returns Adjusted max token budget */ export declare function applyCalibration(maxTokens: number, state: PruneCalibrationState): number;