---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/context/thrift/subtractive_pass/functions/resolveBudget.md
---

# Function: resolveBudget()

```ts
function resolveBudget(
  contextWindow: number,
  outputReserve?: number,
  reserveFraction?: number,
): number;
```

Defined in: [src/batteries/context/thrift/subtractive\_pass.ts:338](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/thrift/subtractive_pass.ts#L338)

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](../variables/DEFAULT_RESERVE_FRACTION.md).                                                                                                                                      |

## Returns

`number`
