/** * Model context-window resolution for the compaction trigger. * * Compaction asks "how full is the window?". That question needs a WINDOW, * and the runtime previously answered it with `turnConfig.tokenBudget` — the * turn's cumulative spend cap. The two are different quantities, and using * the second as the divisor for the first is self-defeating: cumulative * spend always exceeds the live window, and the guard force-finalizes at * 0.9 x tokenBudget while compaction needs 0.7 x the same number, so the * mechanism raced its own budget. With the shipped CLI's * `tokenBudget: 1_000_000` the trigger sat at ~700k — far past any window * it targets. * * The table is a floor, not an oracle: a host that knows better passes * `contextWindowTokens` explicitly and this file is never consulted. * * "Floor" governs the model we do NOT recognise — that is what * `DEFAULT_ASSUMED_CONTEXT_WINDOW` is for. It does not license a wrong * number for a model the table names. Every entry below carried 200k for * the whole Claude family, including the models whose window is 1M, and * understating a window by 5x is not caution: the trigger fires at 0.7 x * the divisor, so a 1M-window run compacted at ~14% full. Each of those * runs paid a summarization pass it did not need and threw away the prompt * cache prefix to do it. * * The values are read off the published model comparison rather than * recalled. The durable fix is to ask the provider — the Models API * reports a window per model id — which would end the drift this table * accumulates every release. Until a driver does that, an entry here is * only ever as fresh as the day someone checked it. */ /** * Conservative default for a model we do not recognise. * * Under-estimating is the safe direction: it compacts earlier than needed, * costing a summarization pass. Over-estimating means the turn dies on a * provider `context_length_exceeded` with nothing recoverable. */ export declare const DEFAULT_ASSUMED_CONTEXT_WINDOW = 128000; /** * Best-effort context window for a model id, or `undefined` when the id is * unrecognised. Gateway-qualified ids that prefix or namespace the * model name are handled by substring matching rather than a strict * prefix, since the same model ships under several namespaced ids. */ export declare function lookupContextWindow(model: string | undefined): number | undefined; export interface ResolvedContextWindow { readonly tokens: number; /** * Where the number came from, ranked in that order. * * `'provider'` sits between the two for a reason: a host that set a * number said what they want and outranks any discovery, while the * table is a guess maintained by hand and the vendor's own answer is * not. */ readonly source: 'config' | 'provider' | 'model-table' | 'default'; } /** * Resolve the window the compaction trigger measures against. * * Note what is NOT in the precedence list: `tokenBudget`. It is the wrong * quantity and having it as a fallback is what made the whole compaction * subsystem inert in every shipped consumer. */ export declare function resolveContextWindow(configured: number | undefined, model: string | undefined, /** * What the driver said, already resolved. * * A plain number rather than a promise, because both call sites are * synchronous and sit in the hot loop. Resolving happens once at the * start of a turn; this parameter is that answer being carried in. */ providerReported?: number): ResolvedContextWindow; //# sourceMappingURL=context-window.d.ts.map