Function: resolveBudget()
ts
function resolveBudget(
contextWindow: number,
outputReserve?: number,
reserveFraction?: number,
): number;Defined in: src/batteries/context/thrift/subtractive_pass.ts:338
Resolve the per-dispatch INPUT token budget from the ACTIVE model's window: the window minus the room held back for the model's own output. The same call works for a 4K model and a 1M model.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
contextWindow | number | undefined | The active model's context window (input + output share it). |
outputReserve? | number | undefined | The EXACT number of tokens to hold back for output — pass the generation maxTokens the model is configured with. When omitted, falls back to reserveFraction of the window (a guess, for callers that don't know the cap). Clamped so the reserve never exceeds the window. |
reserveFraction? | number | DEFAULT_RESERVE_FRACTION | The fallback fraction used when outputReserve is omitted. Default: DEFAULT_RESERVE_FRACTION. |
Returns
number