Token Budgets for Superintelligent Agents: Caps That Stop Loops
Set per-task token and step caps for an AI agent, log every cap hit, and decide when a person should take over instead of another retry.

A token budget for an AI agent is a hard limit on how much model work and tool activity a single task may consume before the run stops on its own. Set it per task type rather than per account, and attach a stop action to it: when a cap is reached, the agent halts, records what it did, and passes the case to a named person. Caps are the last line of defense against loops, so they work best alongside clear task design rather than in place of it.
Key takeaways
- Cap each task type on several dimensions at once: tokens, model turns, tool calls and elapsed time.
- A cap only protects you if hitting it changes the run's state, not only the invoice.
- Log every cap hit with the task, the step where it stopped and the last tool result.
- Allow a retry only for failures known to be transient, then escalate with the decision attached.
- Review caps against real runs on a schedule, because a cap set too low breaks good work as surely as a missing cap lets bad work run.
What a token budget should actually limit
A common first attempt is a single monthly spending ceiling on the model account. That protects the finance team, but it reacts too late: by the time the total moves, a looping agent may have repeated the same failing action for hours. An operational budget works at the level of a single run and measures the things that actually grow during a loop.
For most business agents, four limits are worth setting together. The first is input and output tokens per run, which captures how much context and generated text one task consumes. The second is the number of model turns, which catches an agent that keeps deciding to try again. The third is tool calls per tool, because a looping agent often hammers one integration while everything else looks normal. The fourth is elapsed time, since a stuck run can stay within its token limits while waiting on a slow service.
Each limit catches a different failure. A token cap alone will miss a run that makes many short calls. A tool-call cap alone will miss one long, expensive reasoning step. Together they form a boundary that is hard to slip past quietly.
How to set per-task caps, step by step
Start from evidence, not from a guess about what the agent should need. The sequence below is a practical starting point, and it works without any special tooling.
- Name one task type, such as answering a routine customer question from approved documents or preparing a draft invoice for review.
- Pull a set of recent runs for that task from your logs, or run the agent in shadow mode if no history exists. Separate the runs that completed cleanly from those that needed a person.
- Record the typical value for each of the four limits across the clean runs. Look at the spread, not only the average.
- Set a soft limit comfortably above the typical clean run. Crossing it triggers a warning and a log entry, but the run continues.
- Set a hard cap above the soft limit, high enough that unusual but legitimate cases can finish, and low enough that a loop cannot run for long.
- Attach a stop action to the hard cap: the agent halts before any further external write, saves its state and creates a handoff item for a named owner.
- Test the caps on purpose. Give the agent a task designed to make it repeat, and confirm that the halt, the log and the handoff all happen without manual rescue.
The two thresholds serve different purposes. The soft limit is an early signal you can review in daylight. The hard limit is the safety stop that runs even when nobody is watching.
Why loops slip past simple caps
Caps catch runaway work, but they do not explain it. Most loops that waste budget share a few patterns. The agent calls the same tool with slightly different arguments, mistaking a small change in wording for new progress. It receives an ambiguous error, decides the error is its own fault and tries again with a fresh plan that carries the same flaw. Or it fails at one step, and a retry wrapper repeats the whole task from the beginning, including the steps that already succeeded.
That last pattern deserves a specific check. If a retry re-sends a write, such as a booking or a payment instruction, the cap may stop the loop only after the damage is done. Writes need to be safe to repeat before retries are allowed at all. A call that times out may also have succeeded on the other side, so the agent should report that outcome as unknown rather than failed.
Session-level limits matter too. An agent that works through a queue can stay within every per-task limit while starting hundreds of tasks. Put a separate limit on how many tasks one run may spawn, and on how many runs of the same type may be active at once. Guidance on building agent systems commonly recommends explicit stopping conditions for exactly this reason. For more on stuck runs, see AI agent stuck in a loop: stop conditions that actually work.
What to log when a cap is hit
A halted run is only useful if someone can see why it halted. A generic error such as "limit reached" leaves the owner to reconstruct the case from scratch. A useful record is short and specific, and it should sit alongside your other agent traces so it can be read during the weekly review. OpenTelemetry's observability primer describes traces and spans as a shared vocabulary for this kind of record.
- The task identifier, the task type and the version of the agent configuration in force.
- Which limit was hit, whether it was the soft or hard value, and the measured value at that moment.
- The step number where the run stopped, and the last three actions in order.
- The most recent tool result, including whether it was an error, a timeout or an empty response.
- Whether any external write happened during the run, and if so, which records it touched.
- The handoff item created, its owner and the time it was assigned.
Teams often add one more field: a single sentence stating what the agent believed it was trying to accomplish. That sentence frequently reveals whether the loop came from a misread instruction, missing context or a tool that returned something the agent did not expect. For a deeper treatment of what to capture, see AI agent observability: what should you actually log?.
When to escalate instead of retrying
The hardest decision is not whether to stop, but what happens next. A cap that halts the run and then does nothing leaves work stranded. A cap that always retries simply repeats the loop more slowly. Escalation is the middle path: the agent passes the decision to a person, with enough context that the person can decide quickly.
Use this decision guide whenever a cap is hit or a step fails:
- If the failure is known to be transient, such as a brief service interruption with a clear error code, allow one retry after a pause, then stop.
- If the same step has failed twice with the same error, stop and escalate. A third identical attempt rarely changes the outcome.
- If the run has already written to an external system, escalate before any further action, and do not retry the write.
- If the missing piece is a business decision, such as an exception to a policy, escalate with the options rather than the raw log.
- If a person has already approved this type of case, the agent may proceed within the stated limits and record the precedent.
A retry is a guess that the world has changed. An escalation is a request for someone who can tell whether it has.
Illustrative scenario, not a real case: an agent drafting replies to supplier emails hits its tool-call cap while looking up the same purchase order three times. The halt log shows the order lookup returned an empty result each time. The handoff goes to the operations lead with the email thread, the three lookups and one question: is this order archived or missing? The lead answers within minutes, and the agent's note about where archived orders live becomes a rule for future runs. The loop cost a handful of calls, not a day of queued work.
For the escalation side in more depth, see Human escalation for AI agents: send the decision, not the mess. For how retries should be bounded, see An AI agent retry policy that avoids repeated mistakes.
How Be Human handles token caps in managed operations
In managed operations, Be Human treats the budget as part of the agent's operating contract rather than a setting buried in a configuration file. Each agent role is defined with its tasks, memory, tools, approval boundaries and caps, and every change to those is recorded in a change log the owner can read. Monitoring watches the four limits and the stop events, incident response handles halts that need investigation, and recurring evaluations check whether the caps still fit the work the agent actually does. Service is remote and available in English and Portuguese.
Keep caps honest after launch
A cap is a hypothesis about normal work, and normal work changes. A new product line, a revised policy or a different supplier can make a previously safe limit too tight. Review the caps on a fixed schedule, using the halt log as the main input. Read every halt during the first few weeks, then move to a sample as the pattern stabilizes. A correct halt caused by a legitimate spike is a reason to raise the soft limit after review, not a reason to remove the cap.
Keep a short record of each change: the old value, the new value, the reason and the person who approved it. That record also helps the next person understand why a limit looks unusual. For a routine that covers this alongside other agent checks, see AI Agent Support and Maintenance: A Monthly Routine for Healthy Agents.
Take the free Be Human AI diagnostic to find the first task worth handing to an agent.
Frequently asked questions
What is a token budget for an AI agent? A token budget is a limit on how much model usage and tool activity one task run may consume before it stops. It usually covers input and output tokens, model turns, tool calls and elapsed time, so loops are caught even when the token count alone looks modest. The most useful budgets attach a stop action, such as saving state and creating a handoff for a named owner.
How many steps should I allow an agent per task? There is no universal number, because the right value depends on what a successful run of that task normally requires. Measure clean runs from your logs or from shadow mode, set a soft limit comfortably above the typical run, and set a hard cap above that. Review both values after the first few weeks, since real volume usually reveals cases the first estimate missed.
Should a looping agent retry or escalate? It should retry only when the failure is known to be transient, and only once or twice with a pause between attempts. If the same error repeats, or if the run has already written to an external system, the agent should stop and escalate with the context and the decision needed. Retrying a write without a safety check is the pattern most likely to create duplicate work.
Do I need special software to enforce caps? Not necessarily, because the logic can live in the agent's run harness as counters for tokens, turns and tool calls, checked before each step. What matters more is that enforcement happens outside the model's own judgment, so a looping agent cannot argue its way past the limit. If your current setup cannot count these values per run, that gap is the first thing to fix.
Your next step
See where an AI agent fits in your company first.
Take the free Be Human AI diagnostic. A few questions about your work show which task to hand to an agent first, what it needs to know and where a person approves.
Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.


