How It Works
Quick Start
How It Works
Each tool call checksget_tool_budget(tool_name) — falling back to default_tool_output_max when no per-tool rule exists. Protected tools skip pruning during context optimisation.
Configuration
Via ManagerConfig
Via environment
Methods
| Method | Purpose |
|---|---|
set_tool_budget(name, max_tokens, protected=False) | Set limit for one tool |
get_tool_budget(name) | Read limit (falls back to default) |
truncate_tool_output(name, output) | Truncate to the tool’s budget |
Truncated outputs are persisted to disk so the agent can retrieve them — see Tool Output Store.
CLI Usage
Best Practices
Set lower limits for verbose tools
Set lower limits for verbose tools
Web search and file reads return large payloads — cap them at 2,000–5,000 tokens so they do not crowd out conversation history.
Give code execution higher limits
Give code execution higher limits
Code tools often need full stack traces or build logs — 10,000+ tokens prevents losing error context mid-debug.
Mark critical tools as protected
Mark critical tools as protected
protected=True keeps a tool’s output from being pruned during context optimisation, even when the window is tight.Monitor usage via the ledger
Monitor usage via the ledger
Run
/context in chat or call get_stats() on the context manager to see which tools consume the most tokens.Related
Context Manager
Unified facade for budgeting, compaction, and monitoring.
Tool Output Store
Retrieve full outputs after truncation.

