Give each AI workflow run a maximum number of tool calls, an elapsed-time deadline, and a defined place for unfinished work to go. Enforce those limits in the software running the workflow. A sentence asking the assistant to stop after a few attempts is an instruction; it is not an independent control over execution.
For a small business, the useful question is concrete: how much searching, checking, or revising may one inquiry consume before somebody must look at it? The budget belongs to that inquiry from start to finish, including branches and retries. It is separate from the provider’s account spending limit and from the retry setting on one failed connection.
Define the unit you are counting
Ask the builder what their platform calls a step, turn, tool call, and retry. These may count different things. One model response might request three tools, while one tool might make several attempts to reach another service. A limit of ten model turns therefore need not mean ten external operations.
Write a local counting rule. For example, charge one unit before each permitted tool invocation begins, count failed invocations too, and give internal retries a separate documented cap. If a search tool makes several network requests internally, record that boundary rather than claiming the outer counter measures every request. Restrict high-impact actions separately; a budget does not authorize them.
Use more than one boundary
| Boundary | Question it answers | What the builder must define |
|---|---|---|
| Total tool calls | How many operations can this run start? | What consumes a unit and how branches share the counter |
| Elapsed-time deadline | How long can the run remain active? | Start time, treatment of waits, and enforcement during a slow call |
| Repeated equivalent requests | Is the assistant doing the same thing again? | Which tool and normalized inputs count as equivalent |
| Delegation depth | Can a helper keep creating more helpers? | Whether delegation is allowed and the maximum depth |
| Output size | Can one response overwhelm the next step? | Maximum result size and the response when exceeded |
These are design choices, not universal recommended numbers. OWASP’s AI Agent Security Cheat Sheet recommends limits on tool chains, retries, tokens, and cost. Anthropic’s architectural guide also describes explicit stopping conditions, including a maximum iteration count. Neither supplies a suitable operating budget for your particular customer process.
Choose a starting budget from the intended path
Map the ordinary successful path before selecting the cap. An inquiry assistant might fetch an order, look up one policy, and prepare a draft. That gives you a reason to investigate a run making twelve lookups, even if twelve is inexpensive. A research assistant with several approved sources has a different intended path.
Use nonproduction cases to see where legitimate work needs another lookup. Include missing records, conflicting policies, slow services, and a tool that repeatedly returns an unhelpful answer. Choose a conservative initial budget that accommodates the intended task, then review the stops. Do not raise it simply because the assistant used everything available.
Keep one budget across the whole run
Ask for a shared run identifier and a counter stored outside the model’s conversation. A child task must inherit the original run’s remaining allowance. Renaming a task, switching tools, restarting a worker, or asking a helper to continue must not silently create a fresh budget.
Concurrent branches need an atomic reservation before starting a tool. Otherwise two workers can both see one remaining unit and both spend it. For an owner reviewing a proposal, the acceptance question is simple: can the builder demonstrate that the cap still holds when two branches request the final unit together?
A deadline also needs enforcement while a tool is waiting. Checking the clock only after a request returns cannot stop a request that never returns. Specify request timeouts and a supervisor deadline. If cancellation cannot interrupt a remote operation, stop launching new work and preserve the operation’s uncertain status until it is checked.
Make exhaustion an honest outcome
Use a state such as stopped_for_review, with a reason identifying the exhausted boundary. Save the completed lookups, remaining question, and any action already attempted. Assign a review owner. Do not turn a partial answer into a completed ticket because the workflow needs a final status.
Restarting should require a deliberate decision about what remains. If a booking change may already have happened, verify its state before repeating it. An increased budget should be recorded as an exception for that run, not achieved by repeatedly starting new runs until something succeeds.
Hypothetical example: a six-call allowance
Imagine a service business gives an internal inquiry assistant six tool invocations and a 90-second deadline. These are invented settings for illustration. It makes two record lookups, two policy searches, and one availability check: five calls used, one remaining. A helper then requests two more lookups. Only one can reserve the final unit; the other is denied before execution. Total calls started remain six.
If the deadline arrives after four calls instead, the run stops at four. The two boundaries are alternatives: whichever is reached first blocks new work. The review record says which information is missing and confirms that no customer message was sent. This example predicts no cost savings or completion rate.
Builder acceptance checklist
- Define what counts, including failed calls and internal retries.
- Share counters and deadlines across branches and restarts.
- Reserve allowance before execution, including concurrent requests.
- Test repeated requests, a slow tool, and attempted delegation.
- Stop with an explicit reason and an accountable review owner.
- Check uncertain side effects before authorizing a restart.
Sources
- OWASP AI Agent Security Cheat Sheet: supports enforcing limits on tool chains, retries, tokens, and cost.
- Building effective agents (Anthropic): supports explicit stopping conditions for agent loops.



