Guides

Setting Deadlines and Time Limits for AI Agent Runs

How long should an agent be allowed to run before something stops it? The honest answer is that there is no single clock to set. There are four different limits, they stop four different failures, and most runaway runs happen because only one of them was set, usually the wrong one.

Published 2026-10-29 · Last updated 2026-10-29

Four limits that all get called a timeout

Start with the vocabulary, because the settings panels and framework documents use these words loosely. A per-step timeout bounds one unit of work: a single model request, or one tool call. A whole-run deadline bounds everything the run does, start to finish. A step or turn cap bounds how many rounds of work the agent may take, regardless of how long each round lasts. A work budget bounds the total the run may consume, requests, tool calls, tokens, or cost. Framework documentation keeps these separate for a reason: Pydantic AI, for example, documents a per-attempt timeout on a model request, a separate request_timeout that covers the whole request across every retry attempt and the reading of a streamed response, a tool-call timeout, and a run-level timeout= as distinct mechanisms with distinct failure modes.

The four limits, side by side
LimitWhat it boundsWhat happens when it fires
Per-step timeoutOne model request attempt, or one tool callIn Pydantic AI, a timed-out tool call hands the model a retried result reading “Timed out after N seconds”; a timed-out model request fails that request
Whole-run deadlineEvery model request, tool call, and hook in the runThe run is cancelled and, in Pydantic AI, raises RunTimedOut carrying everything the run completed
Step / turn capThe number of steps or turns, not the secondsThe OpenAI Agents SDK raises MaxTurnsExceeded; LangGraph raises GraphRecursionError when its step maximum is exhausted
Work budgetTotal requests, tool calls, tokens, or costPydantic AI's UsageLimits raises UsageLimitExceeded when the run's total work crosses the line

The row that surprises people is the third. A step cap counts steps. It says nothing about how long a step may take or what it may spend, which is why a run can sit comfortably inside its step cap and still run long. The cap's real job is narrower and vital: LangGraph's own reference states that its step maximum exists to prevent infinite loops. Loops are a count problem. Hanging tools and slow services are a time problem. Each limit earns its place by stopping the failure the others cannot.

The defaults, checked against the documentation

Defaults matter because most runs use them. Three checks against the frameworks' own documentation, made on 2026-10-29:

None of these defaults is wrong. All of them are generic. A 10-turn cap that suits a question-answering agent will strangle a research agent that legitimately needs more rounds, and a 300-second read timeout is an eternity inside a run that was supposed to answer in under a minute.

Why per-step timeouts alone do not add up

The commonest configuration error is setting a timeout on each tool and assuming the run is bounded. It is not. Five tools with a ten-second timeout each make a fifty-second turn, and an agent can take many turns. The fix documented in practitioner writing on agent deadlines is a single run deadline that individual calls inherit: each call gets the smaller of its own normal maximum and the time actually remaining. A tool that would normally get ten seconds gets three if only three remain, so the run keeps its overall promise even when individual steps run slow.

The same inheritance runs downward. In Pydantic AI, an agent run from inside a tool, a delegated sub-agent, inherits the parent run's deadline. Its own timeout can make that deadline earlier, never later. That one rule prevents the quietest deadline failure of all: a parent run that ends on time while the sub-agents it spawned keep working, and spending, underneath it. Per-tool budgets still matter within the deadline, because tools differ: one published example table gives a document search 5 seconds, an order lookup 3 seconds, a report generator 30 seconds, and sending email 8 seconds, with a 10-second default for everything else. A single uniform timeout is either too short for the report or too generous for the lookup.

Picking your numbers

One sizing rule covers the wall-clock deadline: base it on your longest normal run, plus headroom. Not the average run, the longest run that was still doing legitimate work. A deadline set at the average kills healthy long runs; a deadline set at the longest normal run plus headroom kills only the runs that have left normal behind. Apply the same logic to the step cap: count the steps a healthy run of this task actually takes, then set the cap above that count, not at a framework default chosen for somebody else's workload.

Two structural rules complete the setup. First, an alert is not a brake. A dashboard or a notification tells a human, and the human may not be watching; a budget check sits in the path of every call and acts the moment the line is crossed. Keep the alerts, but let the limits do the stopping. Second, set limits at more than one level. A per-run limit catches the single runaway task. A per-agent daily budget catches the slower failure where every individual run looks reasonable and the total quietly is not.

Set the limits before the run: a short procedure

  1. Time three normal runs of the task, end to end, and note the step count of each. Use the longest time and the highest step count, not the averages.
  2. Set the whole-run deadline at that longest normal time plus headroom, in the run settings or in the instruction you give the agent where the tool exposes no setting.
  3. Set the step or turn cap above the highest healthy step count. If the tool shows a default, 10 turns in the OpenAI Agents SDK, decide whether it fits this task instead of inheriting it silently.
  4. Set per-step timeouts for the slowest tools the run uses, sized to the tool: lookups get seconds, generators get longer, nothing gets unlimited.
  5. Add the work budget where the platform offers one, a token, request, or cost ceiling per run, so a run that stays inside its time and step limits still cannot spend without bound.
  6. Write down what should happen when a limit fires: stop and report, return partial results, or hand the task to a human. Decide now, not at the moment of the alert.

What success looks like: a normal run finishes untouched by every limit; a stuck run stops at the deadline with its completed work saved and a report you can act on; and no run, including any sub-agent it delegated to, continues past the deadline you set.

When a limit fires: keep the work, then decide

A fired limit is information, and the first job is not to waste what the run already did. A timed-out run is not necessarily an empty one: Pydantic AI's RunTimedOut carries everything the run completed, and that history can be passed into a new run as its message history to resume rather than restart. The equivalent habit in any tool is the same: read the partial output and the record of where the run stopped before deciding anything.

Then make the decision the limit was bought to force. If the run was looping, repeating steps without progress, the step cap did its job; shrink or re-scope the task rather than raising the cap, because a loop given more steps is just a longer loop. If the run was progressing steadily and simply ran out of road, the task is bigger than its deadline: raise the limit deliberately, or split the task into two runs with a checkpoint between them. If one tool consumed the whole deadline, the per-step timeout for that tool is the fix, not the run deadline. What a fired limit should never produce is the reflex response, raising every number until the alerts stop. The numbers were the diagnosis. Treat them that way.

, Dex Carter, Tech Writer