import type { IterationContext } from './context.js'; export { isCompactionMessage } from '../../../../compaction/summary.js'; /** The selected request model owns the denominator, including overflow recovery. */ export declare function activeContextWindow(ctx: IterationContext): import("../../../../compaction/context-window.js").ResolvedContextWindow; /** * How full the context is, in tokens. * * Prefer the provider's own count of the last prompt — it is a measurement, * not a guess, and it includes everything the heuristic cannot see (tool * schemas, system blocks, image tokens, per-message framing). The chars/4 * estimate remains the fallback for iteration 1, before any turn has * reported, and for providers that do not return usage. * * The measurement describes the prompt as it was SENT, so everything the * turn appended afterwards — the assistant message and every one of its * tool results — falls outside it. Reading it verbatim therefore reported * a context one full turn stale, and staleness is largest on precisely the * turns that add the most: a turn that returns 200 KB of tool output was * counted as if it had returned nothing. That error and the missing tool * catalogue both point the same way — under-count — so the trigger did not * jitter around the threshold, it sat systematically late. The tail is * estimated rather than measured because no provider in the repo exposes a * token-count call; an approximate tail beats a certain omission. */ /** * How large the context being sent is right now, and whether that number was * counted or estimated. * * Exported because it is the only honest answer to "how much room is left", * and the surfaces that ask are outside this file. It was internal, so a host * wanting the figure had to derive one — and a host did, from cumulative run * spend divided by a window guessed from a model name, which is neither term * of the right fraction. */ export declare function measureContext(ctx: IterationContext): { tokens: number; source: 'provider' | 'estimate'; }; /** * Shed history because the PROVIDER said the prompt is too long. * * The threshold path guesses when to compact and can guess low — the * estimate is a heuristic, and a turn carrying images or a language the * chars-per-token ratio does not fit will hit the real window while still * reading as comfortable. When that happens the provider tells us exactly * what is wrong, and the kernel already classifies it precisely and then * did nothing with it: the call was correctly marked non-retryable * (resending the identical prompt cannot help) and the turn died holding a * compaction subsystem that could have made room. * * Forced rather than threshold-gated, because the threshold is the thing * that was just proven wrong. * * @returns whether anything was actually shed. `false` means retrying would * send the same prompt again, so the caller must not. */ export declare function relieveOverflow(ctx: IterationContext): Promise; export declare function runCompactionCheck(ctx: IterationContext, options?: { force?: boolean; }): Promise; //# sourceMappingURL=compaction.d.ts.map