Agent Timeouts and Cancellation: Clean Stops for Long AI Tasks
How to set AI agent timeouts in tiers and define cancellation so a long task stops cleanly, without half-written records in your systems.

An AI agent timeout is a limit that stops a task when it runs too long, stalls, or spends more than its allowed budget. A clean timeout also defines what happens next: the agent stops starting new work, closes or marks the writes already in progress, records why it stopped, and releases what it was holding. The goal is a stopped task that leaves your records consistent, not one that disappears partway through a change.
Key takeaways
- Set timeouts in tiers (per call, idle, whole-task deadline and budget), because each tier catches a different failure.
- Treat cancellation as a fixed sequence: stop new work, settle open writes, log the reason, then release resources.
- Give every agent-written record a state the harness controls, so an interrupted change is visible as pending, unknown or abandoned.
- Retry only with the same idempotency key or after checking the target system, so one request never becomes two records.
- Let the business owner of the outcome decide the limits, and review them after every incident.
Why a timeout is more than a stopwatch
A timeout is usually described as a number: stop after a certain amount of time. For a business agent, the number matters less than what is in flight when it fires. An agent that is partway through creating a quote, reserving a crew slot and sending a confirmation can be cut off after the first two steps. The customer has no confirmation, the scheduling system shows a slot that nobody can see in the quote, and no one knows which step failed. The problem is not that the agent ran too long. The problem is that the stop was never designed.
Long tasks make this more likely. They call several tools, wait on slow external systems, and sometimes loop when a tool returns an unexpected result. The harness, meaning the code that surrounds the model with tools, permissions, logging and limits, is the layer that enforces every stop. If the harness has no clear rule for what a stop means, each stop becomes a guess. For a general introduction to that layer, see what an AI harness is.
The four timeout tiers
One limit for the whole run is too coarse. It either cuts off a slow but healthy step or lets a stuck loop run far longer than anyone intended. Separate limits catch separate failures:
- Call timeout: the maximum wait for one tool call or one model response. When it fires, the harness treats that call as failed or unknown, never as completed.
- Idle timeout: the maximum time without any progress signal, such as a new tool result or a saved checkpoint. It catches stalls that a total limit would only catch much later.
- Task deadline: the maximum wall-clock time for the whole run, set by the business need. A quote that must be ready before a dispatch cutoff has a different deadline from a nightly reconciliation.
- Budget limit: the maximum number of steps, tool calls or model tokens for one run. This is the guard against loops and runaway cost, and it is covered in more depth in token and step budgets for agents.
Each tier should have its own value, and each value should have a written reason beside it. A reviewer who cannot see why a limit exists will either ignore it or loosen it without understanding the risk.
What a clean cancellation does, in order
Cancellation is different from a crash. A crash leaves the harness to guess what happened. A clean cancellation is a signal the agent can act on, followed by a sequence that the harness controls. The order matters because the agent should not begin new work while it is still closing old work.
- Stop starting new tool calls and subtasks as soon as the cancel signal arrives.
- Let a write that is already in progress finish if it is short and can be verified. If it cannot be verified in time, mark it as unknown rather than guessing.
- Compensate for any change that left the record inconsistent, such as a status update that was saved without its matching note.
- Write a closing entry with the reason for the stop, the last confirmed step, and the state of every open item.
- Release locks, reservations and sessions the run was holding, then end the run.
Hard termination should be the last resort. Give the grace period a fixed length and make it part of the design. A reasonable starting shape is a short grace period for writes and a longer one for read-only steps, since a read can be repeated safely and a write may not be. The distinction between an interrupted read and an interrupted write is the one teams most often skip.
Keep half-finished work visible, not hidden
The records problem is what makes a timeout dangerous. Most business systems have no concept of a change that has started but not been confirmed. The harness has to add that concept. Give each agent-written record a state field that the harness controls, and make the states explicit:
- Pending: the agent has started the change and has no confirmation from the target system yet.
- Committed: the target system confirmed the change, so the record can be read as final.
- Abandoned: the run stopped before the change was confirmed, and a person or a later run must decide what happens next.
- Unknown: a call timed out and the agent cannot tell whether the side effect occurred.
Retries need the same care. A provider-defined idempotency key lets a repeated request return the original result instead of creating a second record. The [Stripe documentation on idempotent requests](https://docs.stripe.com/api/idempotent_requests) is a clear example of this pattern. Where the target system offers no such key, the harness should look up the record before it retries. It should never assume that the first attempt failed just because no response came back.
A cancellation plan you can review
Write the plan before the first long run, and store it with the agent's other configuration so that a reviewer can read it without reading code. A usable plan answers these questions:
- Which tools can the agent call, and which of them write data rather than only read it?
- For each write, which target system and record does it change, and what confirmation does the harness expect back?
- What are the four tier limits for each task type, and why was each value chosen?
- How long is the grace period, and what happens to a write that does not finish inside it?
- Who receives an abandoned or unknown record, and how soon must that person act?
- Has the plan been tested by cancelling a run at every write step, not only at the end?
Illustrative scenario: a service company's agent creates a quote, reserves a crew slot and then emails the customer. The call timeout fires while the slot reservation is still pending. Under the plan, the harness marks the reservation as unknown, checks the scheduling system for a matching slot on its next run, and places the item in the operations queue with the quote reference and the last confirmed step. No customer email goes out until a person confirms the slot.
The same scenario also shows why the run's trace matters. Traces and spans, described in [OpenTelemetry's observability primer](https://opentelemetry.io/docs/concepts/observability-primer/), give each stopped run a record of where it stopped, which is the first thing an operator needs when a record looks wrong.
How Be Human handles timeouts in managed operations
Be Human designs the timeout tiers, the cancellation sequence and the record states as part of the harness, before the agent handles live work. In managed operations, the same settings stay under review after launch. That includes monitoring of stalled and cancelled runs, recurring checks that state fields still match the target systems, permission reviews when a tool's behavior changes, and controlled adjustments when a limit turns out to be wrong. Each change is logged with its reason, so the team can see which limit moved, when, and why.
Who sets the limits, and how often should they change?
Limits belong to the person who owns the outcome, not only to the engineer who writes the configuration. A finance lead should decide how late a reconciliation may run and what must happen before a payment record is touched. An operations lead should decide how long a stalled job can sit before it reaches a person. Engineers translate those decisions into settings and keep the reasons next to them. Review the limits after any incident, and on a regular schedule that fits how quickly the workflow changes.
Start conservative. A short budget and a clear human-review trigger are easier to loosen later than a long run that has already written incomplete records. The broader question of when a loop should halt and escalate is covered in stop conditions for agent loops, and it is worth settling alongside the timeout tiers.
If you want to find the first task worth handing to an agent, and the timeout rules that task would need, take the free Be Human AI diagnostic.
Frequently asked questions
How long should an AI agent timeout be? There is no universal value. Set each tier from the business need: how long a customer or deadline can wait, how long a healthy step normally takes, and how much a stalled run may cost. Write the reason beside each value so a reviewer can challenge it.
Is a timeout the same as cancellation? No. A timeout is the trigger, the condition that says a run has gone on too long or stopped making progress. Cancellation is the controlled response: stop new work, settle or mark open writes, log the reason and release resources. A system can time out without cancelling cleanly, and that is the failure this article is about.
What should happen to a write that was interrupted? It depends on the target system and on whether the change can be verified. Short, confirmable writes can finish inside a grace period. Anything that cannot be confirmed should be marked unknown or abandoned and routed to a named person with the last confirmed step attached, rather than retried blindly or left silent.
Can an agent resume after a timeout instead of starting over? Often, yes, if the run saved verified checkpoints before the stop. Resume only from states the harness can confirm, and re-check the target system before repeating any write. The approach is described in checkpoints for long-running agent tasks.
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.


