Skip to main content
The Context Budgeter allocates token budgets across context segments based on model limits and configurable priorities.
The user configures segment priorities; the budgeter allocates tokens before each model call.

Quick Start

1

Configure via Agent

2

Use the budgeter directly

Model Limits

Budget Allocation

Default segment budgets:

Custom Budgets

Overflow Detection

Threshold-Based Triggers

CLI Configuration

Environment Variables

Serialization

How It Works


Best Practices

Set output_reserve for the model’s reply so retrieval and history do not consume the full window.
Pass the correct model name so limits match the provider’s context window.
Trigger compaction or retrieval trimming before hard overflow — do not wait for API errors.
Allocate per-segment budgets when tools return bulky JSON or file contents.

Context Ledger

Track actual token usage by segment

Context Optimizer

Reduce context when over budget