AI Agent Step Limit: Set Caps, Timeouts and Spend Ceilings in a Harness
Learn how to set an AI agent step limit, timeout and spend ceiling in a harness so a runaway run stops early, leaves a clear record and alerts an owner.

An AI agent step limit is a hard cap on how many actions an agent may take in one run, enforced by the harness rather than by the model's own judgment. Paired with a wall-clock timeout and a spend ceiling, it stops a runaway loop before it sends wrong messages, edits the wrong records or spends a budget overnight. Set all three outside the model, test them with deliberate failures, and make every stop produce a record a person can act on.
Key takeaways
- Enforce step caps, timeouts and spend ceilings in the harness, where the model cannot override them.
- Derive each limit from the normal behavior of the task, then leave enough headroom for legitimate long runs.
- Make every limit hit produce a saved state, a clear status and an alert to a named owner, never a silent failure.
- Set spend ceilings at several levels (per run, per day, per agent) and give each level its own action.
- Force loops, slow tools and expensive prompts in a test environment before any agent touches live systems.
Why the model should not be the only thing that stops it
An agent works in a loop: the model reads the current context, chooses an action, the harness runs it, and the result goes back into the context for the next decision. Most of the time this loop ends because the task is done. When something unexpected happens, such as a tool returning an error that the model reads as a reason to try again, the loop can keep going without any new progress. The model is not trying to cause damage. It is doing what it was built to do, which is to keep choosing a next step.
That is why limits belong in the harness. A prompt that says "stop after five attempts" is a request, and requests can be ignored under pressure, misread or lost when the context grows long. A counter in the harness is a fact: the run is halted at the cap whatever the model thinks. Good harness design keeps the model's reasoning focused on the task and keeps the controls on the outside, where a person can read them and change them through a reviewed release.
The three limits and what each one protects against
A step cap counts actions: model turns, tool calls or both, depending on how your harness records work. It protects against repetition, such as an agent calling the same lookup again and again with slightly different wording. A step cap alone does not measure time, so it misses a single tool call that hangs for a long period.
A timeout measures elapsed wall-clock time for the whole run and, ideally, for each tool call. It protects against stalled waits, unresponsive external services and runs that stay open for hours because nobody is watching. A timeout alone can miss a loop of very fast steps that quickly consumes tokens, which is why the three limits work as a set.
A spend ceiling measures cost: model tokens, paid tool calls and any usage charged by a provider. It protects the budget and makes a runaway visible in money, not only in logs. Spend data often arrives later than the run itself, so the ceiling needs estimates during the run and reconciliation after it. The FinOps Foundation's guidance on unit economics is a useful reference for thinking about cost per completed task rather than cost per call.
A limit that the agent can change or ignore is a suggestion. A limit enforced by the harness is a boundary.
- Step cap: protects against repeated or circular actions.
- Timeout: protects against hung tools, stalled waits and forgotten runs.
- Spend ceiling: protects the budget and exposes runs that cost far more than expected.
How to choose the numbers
Do not start from a number you like. Start from observed behavior. Run the task in a test environment with realistic inputs, record how many steps, how much time and how many tokens each successful run used, and note the unusual but legitimate cases. Then set each limit above the normal range with a deliberate margin, so that a good run is never stopped by accident, while a loop is stopped well before it causes harm.
Illustrative scenario: a shipping-status agent answers customer questions by looking up an order, checking a carrier record and drafting a reply. In testing, most runs take three to six tool calls. The team sets a step cap of twelve, a timeout that fits the slowest normal carrier response with room to spare, and a per-run spend ceiling that a person would want to be asked about before exceeding. When a carrier outage causes repeated errors, the run stops at the cap, saves its state and alerts the support lead, instead of retrying for the rest of the afternoon.
When you are unsure, pick the lower value for the step cap and the spend ceiling, and the higher value for the timeout only if a slow tool is legitimately part of the task. Then watch the first weeks of real runs. If legitimate work is halted often, raise the limit through a reviewed change. If runaway runs are never caught, lower it.
A step-by-step plan to add the limits
- Step 1: Name the task and its owner, and write down what a successful result looks like.
- Step 2: Run the task in a test environment with typical and difficult inputs, and record steps, elapsed time and token use.
- Step 3: Set the step cap, the timeout and the spend ceilings from that record, with a visible margin above normal runs.
- Step 4: Decide the action for each limit: halt, save state, alert, or ask for approval before continuing.
- Step 5: Implement the counters in the harness, not in the prompt, and log each limit hit with the run identifier and the reason.
- Step 6: Force each failure on purpose (a looping tool, a slow dependency, a very long input) and confirm the run stops as designed.
- Step 7: Review the first real runs, adjust through a versioned change and record why the number changed.
What should happen when a limit is hit
A limit that simply kills the process is not enough. A clean stop has four parts. First, pending tool calls are cancelled or marked as unknown, so nobody assumes they completed. Second, the harness saves the state of the run, including the last verified step, so a person or a later run can resume from a known point. Third, the run status says why it stopped, using a clear reason such as step cap reached or spend ceiling reached. Fourth, a named owner receives an alert with enough detail to decide what to do next.
The stop should also prevent automatic retries of the same action. A retry after a timeout is dangerous if the first attempt actually reached an external system. Payment and messaging providers often document idempotency keys for this reason: the same request with the same key is processed once, even when it is sent twice. Your harness should use an equivalent pattern for any action that changes a record or sends a message. For the broader design of halting and escalation, see Stop Conditions for AI Agent Loops: When to Halt and Escalate and Agent Timeouts and Cancellation: Clean Stops for Long AI Tasks.
Spend ceilings need more than one threshold
A single hard ceiling on a monthly total is too slow to protect anything useful. By the time the monthly total shows a problem, the damage may already be done across thousands of runs. Use at least three layers. A per-run ceiling stops one expensive run. A per-agent daily ceiling catches a pattern of many moderately expensive runs. A team or account ceiling protects the whole operation. Each layer should have a warning before the stop, so the owner can act while the agent is still working.
Warnings are most useful when they show the cause, not only the total. A spike in tokens per run points to a longer context or a loop. A spike in paid tool calls points to a retry pattern or a new input type. For deeper detail on what to record, see Token and Step Budgets for Runaway AI Agent Loops and Harness Health Checks for Superintelligent Agents: Hourly Signals.
How to test limits before production
Limits that have never been triggered are untested. Before launch, build a short test list and run it in a sandbox that cannot reach live customers or payment systems. Include a tool that always returns an error, a tool that responds slower than the timeout, an input that causes a long reasoning chain and a scenario where the model proposes the same action repeatedly. For each case, confirm four things: the run stopped at the right value, the state was saved, the alert reached the right person and no external action was repeated.
Keep this test list with the agent's version history, so that every change to the prompt, the tools or the model is checked against the same failures. A limit that worked last quarter can quietly stop working after a model swap or a tool change.
How Be Human handles this in managed operations
In Be Human's managed approach, step caps, timeouts and spend ceilings are defined during the first engagement, alongside the agent's role, memory, tools and approval boundaries. They are enforced by the harness, recorded with the agent's configuration and reviewed when the task, the model or the tools change. Monitoring tracks how often each limit is reached, incident response covers runs that stop in unexpected ways, and controlled improvements adjust the numbers through versioned releases rather than ad hoc edits. The aim is that a person can see what the agent did, why it stopped and what changes next.
If you are not yet sure which task should carry these limits first, the free Be Human AI diagnostic can help you find the first task worth handing to an agent.
Frequently asked questions
What is an AI agent step limit? A step limit is a hard cap on the number of actions an agent can take in one run, such as model turns or tool calls. The harness counts the actions and halts the run when the cap is reached, whatever the model decides. It works best with a timeout and a spend ceiling, because each one catches a different kind of runaway.
What step cap should I set for a business agent? Start from observed runs of the same task in a test environment, not from a guess. Set the cap above the normal maximum with a visible margin, so legitimate work is not halted, and lower it if runaway loops are still reaching the limit late. Review the value after the first weeks of real use and change it through a recorded release.
What happens to a task when a timeout or spend ceiling stops the agent? A well-designed harness cancels or marks pending actions, saves the last verified state, records the reason for the stop and alerts a named owner. The task can then be resumed from that state or handled by a person. The run should not retry the same external action automatically, because the first attempt may already have taken effect.
Can the model itself be trusted to stop when the task is complete or stuck? The model should be asked to finish and to report when it is blocked, and that behavior is useful. However, the hard boundary should live in the harness, because a model can misread instructions, lose track of its own history in a long context or keep trying under pressure. Treat model judgment as the first layer and harness limits as the guarantee.
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.


