Agent Reliability

AI Agent Retries and Timeouts: Deadlines, Jitter, and Retry Budgets

Design AI agent retries around end-to-end deadlines, classified failures, jitter, shared budgets, and cancellation without multiplying unsafe side effects.

· · 8 min read

Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.

An AI agent retry policy controls more than network reliability. A single task can pass through a model SDK, a tool executor, an orchestration engine, and a queue consumer. If each layer independently repeats work, a short dependency failure can become a long, expensive run with duplicated actions.

The design goal is to recover from failures that repetition can resolve while preserving the task's deadline, authority, and resource limits. This guide proposes an illustrative policy for a catalog-research agent. Its timings and budgets are hypothetical engineering choices, not measured service performance.

Distinguish a retry from a new decision

A transport retry repeats the same logical operation because its response was unavailable or a transient condition prevented completion. Replanning changes what the agent intends to do. Correcting invalid arguments changes the request. These activities need separate counters and trace events even when all three consume the task's overall budget.

Suppose a search tool times out. Repeating its identical read request can be a transport retry. Asking the model to choose another supplier is a new decision. Reissuing a purchase request with a newly invented action identifier is a new mutation, even if the model describes it as retrying.

Record a logical operation identifier, attempt number, normalized argument digest, and recovery reason. Keep those fields outside model-controlled text. A retry controller should receive a classified outcome from application code, rather than interpreting an apology or a free-form suggestion to try again.

Assign retry ownership before choosing backoff

Inventory the actual execution chain. Check SDK defaults, gateway policies, workflow-node retries, queue redelivery, and any agent-level recovery loop. A setting named maximum retries may exclude the initial attempt; document counts in attempts when calculating the total exposure.

For a hypothetical stack with three attempts at each of three independently retrying layers, one logical request can produce up to 27 leaf attempts. That is arithmetic for the proposed stack, not a benchmark. Partial success and different failure locations change the observed number, but the upper bound exposes the coordination problem.

Google's SRE guidance specifically warns about retry multiplication across layers and recommends considering both per-request limits and a service-wide retry budget. Addressing cascading failures.

Choose one owner for repeating a given remote operation. For example, the executor may handle a small number of transport attempts while the orchestrator handles durable recovery after executor failure. Pass the operation's attempt history across that boundary so durable recovery does not reset the allowance. A queue redelivery should resume the recorded operation, not create an unlimited fresh retry loop.

This ownership decision connects to durable agent workflows, where checkpoint recovery and external-call recovery must agree about what already happened.

Give the whole task one deadline

An attempt timeout limits one wait. An end-to-end deadline limits the complete task, including queueing, planning, backoff, tools, validation, and final response construction. Replacing each expired attempt with a new full timeout can make a nominally short task run indefinitely.

In the proposed policy, each stage receives the remaining task allowance. Before dispatch, the executor subtracts a reserve for verification and response delivery. It starts an attempt only when enough usable time remains for that operation's minimum meaningful timeout. The minimum is workload-specific: an expensive query may have no realistic chance within the last few milliseconds.

Use a monotonic clock for elapsed-time calculations within a process. When crossing processes or persisting a run, use the platform's supported deadline representation and account for clock behavior; a process-local monotonic timestamp is not portable state.

gRPC's documentation explains deadline propagation, including reducing the transmitted timeout by elapsed time. It also notes that language implementations differ in whether propagation is automatic. Check the specific client rather than assuming the framework handles it. gRPC deadlines.

Inspect what the timeout actually covers. Waiting for a connection pool, DNS resolution, connection establishment, response headers, and response-body consumption can have different controls. Amazon's timeout guidance discusses missing coverage and the danger of overly aggressive values. Timeouts, retries, and backoff with jitter.

Classify failures by what can change

A useful recovery table describes evidence and permitted behavior, not just HTTP status families:

Outcome Proposed interpretation Recovery boundary
Invalid schema The request violates a known contract Correct arguments within a separate repair budget
Permission denied The actor lacks authority Stop; repetition cannot grant permission
Dependency throttled Admission was refused Wait only if the task deadline and retry budget allow it
Temporary read failure A safe read may succeed later Repeat the same logical read within limits
Stale resource version Preconditions changed Read current state and reconsider the action
Mutation response lost The effect might already exist Reconcile by action identity before another mutation

These categories are proposed application semantics. A particular service can define exceptions, so derive classification from its documented contract rather than treating every server error as safe to repeat.

For mutations, preserve the original action identity across attempts. AWS's idempotent-API guidance describes caller-provided identifiers and rejecting the same identifier when parameters express different intent. Idempotency still depends on the receiving service implementing the contract. Making retries safe with idempotent APIs. See idempotency for agent actions for the associated ledger design.

Combine jitter with admission and retry budgets

For this illustrative policy, the retry window grows as min(cap, base * 2^retry_index), with the first retry indexed at zero. Draw a random delay within that window. Randomness spreads attempted recovery in time; it does not create capacity or make an unsafe operation repeatable.

If a service supplies a valid Retry-After value, interpret it according to the applicable protocol and service contract. HTTP permits either an HTTP-date or a nonnegative delay in seconds. A parser that always treats the value as milliseconds can immediately violate the intended wait. RFC 9110, Retry-After.

If the required wait exceeds the task's remaining allowance, stop or defer the task through an explicitly durable product workflow. Do not silently shorten the wait. Where permitted, additional jitter after a server-specified minimum can avoid many clients waking simultaneously at that minimum.

Use at least two controls: a cap on attempts for one operation and a shared retry allowance for the dependency. In this proposed design, retry tokens are consumed atomically at dispatch, after waiting and rechecking cancellation. Partition capacity where necessary so one tenant cannot consume every recovery opportunity. Keep ordinary admission control active; a retry should not bypass the concurrency limit simply because an earlier attempt failed.

Also count model repairs and replanning against run-level cost and step budgets. Otherwise the transport layer can be well behaved while the agent repeatedly invents a new operation to evade its practical limit.

Walk through a bounded recovery

Assume a hypothetical catalog task has a 30-second total deadline. Planning consumes four seconds. The executor reserves four seconds for validation and the final response, and requires an eight-second allowance for each catalog request.

The first request times out after eight seconds. The controller draws a one-second backoff. After waiting, it rechecks cancellation, the shared retry token, and the remaining time. Thirteen seconds have elapsed, leaving seventeen; after the four-second reserve, a second eight-second attempt is admissible.

If that attempt also consumes its full timeout, twenty-one seconds have elapsed. Nine seconds remain, but only five are available after the reserve. A third attempt would violate the proposed minimum allowance, so the controller stops. It returns the evidence already collected and identifies the missing catalog check. It does not label an incomplete comparison as verified.

For an order-placement tool, the same timeout sequence would require a different recovery path. A lost response might follow a committed order. Query the operation ledger using the stable action identity; an exhausted foreground deadline can end the user-facing wait while a controlled reconciliation workflow still resolves the uncertain effect.

Test cancellation and failure sequences

Cancellation means the caller no longer wants further work. It does not prove remote effects were rolled back. gRPC explicitly leaves application code responsible for stopping spawned work after cancellation. Server deadline behavior.

Test cancellation during backoff, after dispatch, and immediately before a worker resumes from a checkpoint. Assert that no new attempt starts after cancellation, queued work is withdrawn where possible, and late results cannot overwrite a newer terminal state. Keep uncertain mutations available for authorized reconciliation rather than abandoning their records.

Use a controlled clock and deterministic random inputs in tests. Inject connection failures, delayed bodies, malformed retry hints, SDK-level repeats, queue redelivery, and process crashes. Inspect downstream invocation counts as well as final messages. A successful response after 27 hidden attempts is operationally different from success after two.

Monitor attempts per logical operation, retry-token denial, deadline exhaustion by stage, recovery success, and unknown mutation outcomes. Segment by dependency and operation class; a global average can hide one tool that repeatedly consumes the entire task allowance.

Frequently asked questions

Should the model decide how many times to retry?

The model can propose another investigation step, but application code should enforce transport classification, attempt limits, deadlines, and authority. Narrative reasoning must not reset those controls.

Is exponential backoff sufficient during an outage?

No. Backoff changes timing. Admission limits, shared retry budgets, load shedding, and a useful degraded outcome determine whether the system avoids overwhelming the dependency.

Can cancellation stop a charge or order already submitted?

Do not assume so. Cancellation can prevent future local attempts, while a submitted remote action may already have committed. Reconcile the original action and use an explicitly authorized compensating operation if the business process permits one.

Source reference list

AI Agent Reliability
Retry Budgets
Timeouts
Distributed Systems