Skip to main content
Budget management lets you cap how much an agent spends on LLM calls per run.

Quick Start

1

Set a Budget Limit

2

Check Costs After a Run


How It Works

After each LLM call, the agent checks the running total against max_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)

Raises BudgetExceededError 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.

Configuration Options

Budget is configured through ExecutionConfig:

Multi-Agent Budget

Set per-agent budgets in a team:

Best Practices

Run a few times without max_budget to understand typical costs. Then set limits based on real data.
Use on_budget_exceeded="warn" while building. Switch to "stop" in production to enforce hard limits.
Give each agent its own budget rather than one shared limit. Research agents typically cost more than formatting agents.
When max_budget is None (default), the budget check is skipped entirely. Cost tracking still runs but adds negligible overhead.

Execution

Iteration limits, timeouts, rate limiting

Guardrails

Safety and validation controls