An agent loop can call tools for as many turns as the task requires, and that is also its failure mode: a task the agent cannot finish becomes an endless loop of calls. A step budget is a hard maximum, such as 10 tool calls per task, after which the agent must stop and answer from what it has. Set it before the task starts.
Prerequisites
- An agent loop you control, in code or in a client setting.
- A step budget number, such as 5 or 10.
- A rule for what the agent does at the cap: answer, or ask the user.
Steps
Step 1: Pick the budget
Pick a budget that fits the task: 5 steps for a lookup, 10 for a task with several lookups. Too low stops useful work; too high wastes calls. Start at 10 and adjust from the logs.
Step 2: Count each call
Count every tool call the agent makes, and show the count in the log. A count you cannot see is a budget you cannot enforce.
Step 3: Stop at the cap
When the count reaches the budget, stop calling tools and send a final message: answer from the results already collected, and say what is still missing. Record the missing piece as a follow-up task.
Worked example: Bluebell Bakery supplier search
The fictional Bluebell Bakery gives its agent a budget of 10 tool calls to find a flour supplier.
| Call | Tool | New information | Budget left |
|---|---|---|---|
| 1-3 | search_suppliers | 3 suppliers listed | 7 |
| 4-6 | get_supplier_details | Prices for 2 suppliers | 4 |
| 7 | get_supplier_details | Price for the 3rd supplier | 3 |
| Final | Answer from results | Recommends 1 supplier | Done |
The agent uses 7 of its 10 calls, answers with a recommendation, and 3 calls of budget remain unused.
Expected result. The agent finishes within its budget, or stops at the cap and answers from the results it has. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.
Limits
- A budget does not fix a bad tool description; if the agent keeps calling the wrong tool, fix the description.
- Count tool calls, not turns: one turn can hold several calls.
- This guide does not cover billing limits, which are a separate cap.
