Bounded Iteration & Budget Caps
Every agent loop has explicit limits — max iterations, max tokens, max wall-time, max spend — beyond which it stops and escalates.
This page is the complete instruction page for one pattern called "Bounded Iteration & Budget Caps." It explains the problem this pattern solves, the idea behind the solution, when you should (and should not) use it, and what happens afterward — both the good effects and the costs.
This matters because building AI agents is not just about making them clever. It is also about making them safe and predictable. Following a well-tested pattern like this one helps avoid common mistakes, and shows you exactly which safety rules and regulations it connects to, listed under "Standards Mesh" on this page.
Context
Agents without exit conditions loop. They re-try the same failing tool, re-decide with the same information, burn tokens, and occasionally cost thousands of dollars in a single runaway.
Problem
Unbounded agent loops are an operational and financial hazard.
Forces
- Completeness vs bounded cost
- Strict caps vs legitimate long-horizon work
Solution
Declare per-task budgets: max reasoning steps, max tool calls, max tokens, max seconds, max currency. Track consumption. On breach, halt and escalate with current state summary. Budgets are per-task, per-agent, and per-tenant.
Applicability
- All production agents
- Any agent with tool access
- Any multi-step agent
Anti-Patterns
- "It usually terminates"
- Budgets only at the LLM-call layer, not end-to-end
Consequences
- +Bounded worst-case cost
- +Bounded user wait
- −Occasionally cuts off legitimate long work
- −Requires budget tuning