Skip to content
sync ai agents

Timeouts and retries between agents

Give each hop a timeout that fits inside the deadline of the agent waiting on it, and keep room in that deadline for retries. Retry only calls that are safe to repeat, such as reads or writes carrying an idempotency key. Space attempts with capped exponential backoff plus jitter under a hard attempt limit, and let one layer own the retries. When attempts run out, send the failure up to a person.

How long should one agent wait on another?

Put a deadline on every wait. Amazon's practice is to set a timeout on any remote call, and generally on any call across processes even on the same box. An agent that waits keeps its connection and worker slot busy until the answer arrives or the wait ends.

Choosing the value is the hard part. Amazon notes that a timeout too high reduces its usefulness, because resources are still consumed during the wait. Set too low, it causes too many requests to be retried, which raises backend traffic and latency.

Budget from the top down. If the whole task has 120 seconds, the orchestrator keeps part of that for its own work, hands each downstream agent a slice, and reserves time for the retries it allows. A hop given less time than its work needs will fail on every attempt, so measure each agent's typical latency before you set its slice.

Frameworks expose timeouts at different scopes, so check which one you are setting:

LangGraph also notes that its timeouts rely on asyncio cancellation.

Which calls between agents are safe to retry?

Reads are the easy case: Amazon says read-only APIs are typically idempotent, and its view is that APIs with side effects are not safe to retry unless they provide idempotency. An agent that sends email or files tickets belongs in the second group.

A timeout does not prove the work failed. Amazon points out that a timeout doesn't necessarily mean side effects haven't happened. The callee may have finished after the caller stopped listening.

To make a side-effecting step retryable, send an idempotency key. Stripe's API reference says to use an idempotency key when creating or updating an object, so a request repeated after a connection error does not create a second object. Temporal suggests combining the Workflow Run ID and Activity ID as the key, since that stays the same across retry attempts.

Graph nodes repeat work as well. With a checkpointer, LangGraph says that after an interrupt or retry the affected node runs again from the start of its function, side effects included. It recommends idempotency keys, upserts, or read-before-write checks.

Some failures should not be retried at all. Temporal names bad input data as a reasonable case for a non-retryable error. In the Agents SDK, stateful follow-up requests fail closed when replay safety is unknown.

How should retries back off between attempts?

Grow the wait after each failure and randomize it. Amazon calls exponential backoff the most common pattern, with the wait increasing exponentially after every attempt, and uses jitter, which adds some amount of randomness so retries spread out in time.

The named settings and their defaults differ by tool:

Timeouts and retries interact in the Agents SDK. A timed-out attempt reaches the retry policy flagged with context.normalized.is_timeout set to True, which retry_policies.network_error() matches, and each permitted retry receives a new per-attempt timeout. Size the hop budget for the worst case: attempts multiplied by the timeout, plus every backoff wait.

Where in the stack should the retry live?

Pick one layer. Amazon describes a five-deep call stack where retries at each layer on their own multiply the load on the database, and its practice for low-cost operations is to retry at a single point in the stack.

Microsoft's retry guidance agrees. It suggests the lower-level task fail fast and report the reason to the task that invoked it, which then handles the failure under its own policy. In an agent system, one way to apply this is to let the orchestrator or supervisor own retries while worker agents report errors upward, as in the central orchestrator pattern.

Look for retries you did not configure. The Agents SDK automatically retries conversation_locked errors with backoff, and this compatibility retry happens even without ModelSettings.retry. Temporal says you should typically not write retry logic inside an Activity Definition, because it lengthens the needed Activity timeout.

What stops two agents from waiting on each other forever?

A per-call cap does not bound a whole run, so add a loop limit too. The Agents SDK raises MaxTurnsExceeded past the max_turns limit, counted in agent-loop turns, meaning LLM calls.

Other frameworks have their own caps. LangGraph lets you cap runs with a recursion limit. The ADK LoopAgent takes a max_iterations parameter that limits a loop to a fixed number of cycles. The guide on preventing agent loops covers detection in more depth.

How do I surface a failed hop to a person?

Log early attempts quietly and the last one loudly. Microsoft recommends you log early failures as informational and only the failure of the last retry attempt as an error, so operators are not flooded by calls that later succeeded.

Give the caller something to act on. Runner.run accepts error handlers keyed by error kind, and a max-turns handler can produce a fallback output that is returned to the caller when include_in_history=False.

Then park the work where a person can review it.

Show the reviewer what was attempted and whether its outcome is known.

Which sources does this page use?

What do people ask about timeouts and retries between agents?

  • Should I add a circuit breaker as well?

    Microsoft advises that after a significant number of failed retries, it is better to prevent further requests to that resource and report a failure immediately. Amazon cautions that circuit breakers introduce modal behavior that can be difficult to test.

  • What if the other agent's work takes minutes?

    Avoid holding one open timeout over the whole wait. The A2A protocol describes push notifications as ideal for very long-running tasks that can take minutes, hours or days, and a client whose stream breaks while a task is active can reconnect with SubscribeToTask.

  • How long does an idempotency key stay valid?

    The service you call decides. For Stripe's API v1, keys can be removed automatically once they are at least 24 hours old, and a key reused after pruning generates a new request.

  • Where do I look when a retry storm happens?

    Start with traces that show which layer retried and how often. The guide to debugging multi-agent systems walks through that.

Updated November 2026

Not sure which pattern fits?

Six questions, about a minute. You'll get a pattern, a shortlist and the tradeoffs.

Take the finder

Which related questions can you explore next?