Quick Start
How It Works
After each LLM call, the agent checks the running total againstmax_budget. If the total exceeds the limit, the agent takes the configured action (stop, warn, or call your handler).
What to Choose
Budget Actions
When the budget is exceeded, you control what happens:Stop (Default)
RaisesBudgetExceededError immediately.
Warn
Logs a warning but continues running.Custom Handler
Call your own function when budget is exceeded.Cost Tracking (No Limits)
Every agent tracks costs automatically, even without a budget limit.| Property | Type | Description |
|---|---|---|
agent.total_cost | float | Total USD spent so far |
agent.cost_summary | dict | Tokens in/out, cost, and LLM call count |
Configuration Options
Budget is configured throughExecutionConfig:
| Option | Type | Default | Description |
|---|---|---|---|
max_budget | float | None | Max USD per agent run. None = no limit |
on_budget_exceeded | str or callable | "stop" | Action when budget exceeded |
Multi-Agent Budget
Set per-agent budgets in a team:Best Practices
Start with cost tracking, then add limits
Start with cost tracking, then add limits
Run a few times without
max_budget to understand typical costs. Then set limits based on real data.Use 'warn' mode during development
Use 'warn' mode during development
Use
on_budget_exceeded="warn" while building. Switch to "stop" in production to enforce hard limits.Set per-agent budgets in teams
Set per-agent budgets in teams
Give each agent its own budget rather than one shared limit. Research agents typically cost more than formatting agents.
Zero overhead when disabled
Zero overhead when disabled
When
max_budget is None (default), the budget check is skipped entirely. Cost tracking still runs but adds negligible overhead.Related
Execution
Iteration limits, timeouts, rate limiting
Guardrails
Safety and validation controls

