Step Budget
Cap the number of tool calls or loop iterations the agent is allowed within a single request.
Intent & Description
🎯 Intent
Cap the number of tool calls or loop iterations the agent is allowed within a single request.
📋 Context
A team runs an agent inside some kind of loop — a ReAct loop, a plan-execute loop, a multi-agent debate — where the model is invoked repeatedly to take more steps until it decides it is finished. Each loop iteration costs model tokens, tool-call money, and wall-clock time, and the loop has no naturally bounded length: the model itself decides when to stop. In real traffic, some sessions wander into pathological states where the model keeps deciding to take one more step.
💡 Solution
Define a numeric cap (max_steps=N) in the agent loop. Increment per tool call or per loop iteration. When N is hit, terminate the loop and return the best partial answer with a note that the cap was reached.
Real-world Use Case
- The agent has any kind of loop (ReAct, plan-execute, debate).
- Cost or latency must have a hard ceiling regardless of the agent’s opinion.
- Runaway behaviour must be impossible by construction.
Source
Advantages
- Bounded worst-case cost per request.
- Surfaces pathological prompts as cap-hits.
Disadvantages
- Can hide deeper bugs (the agent really should stop earlier).
- Choosing N is empirical.