AI Agent Stop Conditions: Step, Spend and Error Limits That Halt Work
Set stop conditions for AI agents: fixed limits on steps, spend and repeated errors that halt the run and hand the task to a named person with full context.

A stop condition is a rule that halts an AI agent automatically when a defined limit is crossed, such as too many steps, too much spend or the same error repeating, and then assigns the task to a named person. Good stop conditions are written before launch, enforced by the runtime rather than by the model's own judgment, and tested by deliberately triggering them. The goal is simple: no run should keep acting after it has gone off course, and no run should disappear without an owner.
Key takeaways
- Give every agent three independent limits: a maximum number of steps, a maximum spend per task and a maximum count of repeated identical errors.
- Enforce limits in the execution layer. An instruction telling the model to stop is not a stop condition.
- Each halt must name a human owner and deliver a handoff packet that explains what happened and what is still unknown.
- Halting should preserve state and block further writes, so the person can resume, correct or reject the task without redoing work.
- Test every limit on purpose in a non-production environment before the agent touches live records.
Why runaway actions need limits outside the model
An agent that calls tools in a loop can keep going long after its plan stopped making sense. The failure is rarely dramatic. A lookup times out, the agent retries, the retry returns a partial result, the agent reads that result as a reason to try another tool, and within minutes it has made dozens of calls, touched several systems and spent money on model usage. Each step looks reasonable on its own. The total is what causes damage.
The model cannot be the only safeguard, because it judges its own progress with the same reasoning that went wrong. An agent that is confused about the task is often not aware that it is confused. Limits that live in the runtime, counting calls and cost independently of the model's text, keep working when the model's judgment does not. The NIST AI Risk Management Framework frames AI risk as something to govern, measure and monitor with clear accountability across the system's life. Stop conditions apply the same logic to a single agent run.
Set three limits: steps, spend and repeated errors
Start with three limits, because each one catches a different kind of runaway.
- Step limit: the maximum number of tool calls or agent turns allowed for one task. It catches loops that look busy but make no progress.
- Spend limit: the maximum model and tool cost allowed for one task, plus a ceiling for the whole agent over a day or a month. It catches expensive reasoning and retries that the step limit misses.
- Repeated-error limit: the maximum count of the same error class, such as the same tool returning the same failure, before the run halts. It catches stuck work that a step limit might allow for too long.
Set the numbers from real work, not from guesswork. Review a sample of completed runs, note how many steps and how much cost a normal successful task takes, and place each ceiling comfortably above that range. A limit that halts good work every afternoon will be disabled within a week, and a limit set so high that it never fires protects nothing. Write each number down with its reason, so the next reviewer knows why it exists. The FinOps Foundation frames cloud spend around unit economics, the cost of a unit of delivered work compared with its value, and that framing transfers well to agent tasks. For deeper detail on loop caps, see AI agent infinite loops and stop caps.
A step-by-step plan for writing stop conditions
For a first agent, this plan fits in an afternoon. The aim is a complete cycle of limit, halt, owner and review, not a perfect policy document.
- Describe the task in one sentence, including its inputs and every record the agent may change.
- List each write action and mark it as reversible, approval-required or never allowed without a person.
- Set the step, spend and repeated-error limits from a sample of completed runs.
- Define the halt behavior: stop new tool calls, block pending writes, keep memory and queue state, and mark the run halted with a reason code.
- Name one human owner and one backup for the agent, plus the channel where halt notices arrive.
- Create a handoff template so every halt delivers the same fields in the same order.
- Set a warning threshold below each hard limit, so a person can intervene before the stop fires.
- Review every halt within the week, and change a limit only through a logged decision.
Illustrative scenario: a refund agent that keeps retrying
Illustrative scenario: a support operations team lets an agent check order status and prepare refund drafts for approval. One afternoon the order system begins timing out. The agent retries the lookup, gets another timeout, tries an alternate endpoint and retries again. The repeated-error limit is set at three identical failures from the same tool. On the third timeout the runtime halts the run, blocks any refund draft and sends a handoff packet to the named support operations lead, with the backup in copy. The packet lists the order identifiers attempted, the three timeouts with their times, the fact that no refund was created, and the last completed step. The lead confirms the order system is recovering and resumes the run from saved state rather than starting over. Nothing was duplicated, and no one had to reconstruct what the agent did.
Without the limit, the same afternoon could have produced dozens of lookups, partial drafts and a trail of confused notes that a person would need hours to untangle.
Who receives the handoff and what the packet must contain
A halt is only useful if a named person can act on it within the working day. Each agent needs one owner, a backup and a channel that someone actually watches. The handoff packet should contain these fields:
- Task identifier, requester and the time the run started.
- Reason for the halt, written in the words of the limit that fired, such as step limit reached or third identical error.
- Completed actions, with the records each action read or changed.
- Attempted actions with unconfirmed outcomes, marked as unknown rather than failed.
- Blocked writes, and the exact decision the person must now make.
- Location of the saved state, so the run can resume without repeating completed work.
Write the decision as a question the person can answer quickly, such as whether to resume, correct the input or close the task. The packet should carry the decision, not a transcript. A timeout often means the outcome is unknown rather than failed, which changes what the person must check, so the packet has to say so. The design details are covered in human escalation for AI agent failures and tool timeouts in AI agents.
How to test stop conditions before live use
A stop condition you have never triggered is still a hypothesis. Test in a non-production environment with records that are safe to change, and use simulated failures rather than waiting for a real outage. Check each of the following:
- Trigger the step limit with a task built to loop, and confirm the run halts at the ceiling rather than past it.
- Trigger the repeated-error limit with a tool that keeps returning the same failure, and confirm the count applies only within one task.
- Trigger the spend limit with a long task, and confirm the warning arrives before the hard stop.
- Confirm that a halt blocks further writes, including writes queued by an earlier step.
- Confirm that the handoff packet reaches the owner and the backup, with every field filled.
- Confirm that resuming a halted run continues from saved state and does not repeat completed writes.
- Record the results in the change log, so the limits have a traceable history.
Be Human designs these limits as part of the first engagement, alongside the role, memory, tools, permissions and approval boundaries the agent needs. In managed operations, the team monitors halts, reviews which limits fired and why, runs incident response when a halt reveals a real fault, and keeps permissions aligned with the owners named in each handoff. Limits are treated as operating controls that change only through logged review.
If you are not sure which task in your business is safe to hand to an agent with these limits in place, take the free Be Human AI diagnostic to find the first task worth starting with.
Frequently asked questions
How many stop conditions does one agent need? At least three: a step limit, a spend limit and a repeated-error limit, each with a named owner and a clear halt behavior. Add more only when the agent writes to sensitive systems, such as payments or customer records, and those writes need their own approval boundary. Keep the set small enough that a person can explain each limit in one sentence.
Is a stop condition the same as a kill switch? No. A stop condition halts one run automatically when a limit is crossed, while a kill switch pauses an agent's writes across all runs, usually at the request of a person. Both are useful, and a well-designed system has both. The stop condition handles the common case, and the kill switch handles the case where the agent's behavior is wrong in a way no single limit captured.
Should the agent be allowed to stop itself? Yes, the agent can and should be able to request a halt when it recognizes that it is stuck or uncertain. That request should never replace the runtime limit, because the model may be unable to recognize its own failure. Treat the agent's own stop request as one more signal, and keep the counted limits as the safeguard that always applies.
What if a stop condition fires too often? Frequent halts are information, not a reason to remove the limit. Review each halt in the week it occurred, sort the causes into tool failures, unclear inputs and limits set too low, and fix the root cause first. Change a limit only through a logged decision, so the reason for every adjustment stays visible to the next reviewer.
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.


