Overview
Execution policies help you keep agents under control:
- Cap iterations and wall-clock time
- Cap LLM calls and tool calls
- Optionally track tokens and cost
Policies are enforced by a UsageTracker, which can be attached to a loop (like agent_loop) so each iteration checks budget before doing more work.
UsagePolicy
UsagePolicy describes your limits and what to do when the budget is exceeded.
Examples of limits:
max_steps
max_llm_calls
max_tool_calls
timeout_seconds
It also supports callbacks (e.g. warn when you hit 80% usage).
UsageTracker
UsageTracker is the runtime object that accumulates usage and checks limits.
If you want budgets enforced inside an agent loop, pass a policy into the loop configuration and ensure you record steps/calls as you execute them.
Enforcing limits in loops
The prebuilt agent_loop supports a usage policy via LoopPolicy.execution_policy.
Use budgets when you care about:
- Runaway loops
- Accidental tool spam
- Latency and cost ceilings
Budget limits are guardrails, not a substitute for good stop conditions. Always make your stop condition explicit and test it.
Next steps