How should an agent retry a failed tool call?
An AI agent should retry a failed tool call only when the failure is likely to be temporary or correctable, and the retry can be performed safely.
A good retry strategy is controlled, limited, and based on the reason the tool failed.
First classify the failure
Before retrying, the agent should determine what kind of error occurred.
Potentially retryable failures include:
- temporary network errors
- timeouts
- service unavailable responses
- rate limits
- transient backend failures
Usually non-retryable failures include:
- permission denied
- invalid credentials
- unsupported operation
- permanently invalid input
- business-rule rejection
Retrying a non-retryable error usually wastes time.
Correct the problem before retrying when possible
If the failure came from bad arguments, the agent should fix them first.
For example:
Error: invalid_date_format
Instead of repeating the same call, the agent should transform:
07/10/26
into the format the tool expects:
2026-10-07
Then it can retry.
Use a limited retry count
Retries should always be bounded.
For example:
- attempt 1
- retry 1
- retry 2
- then stop or use another recovery path
Without a limit, the agent can enter an endless loop that wastes tokens, API calls, time, and money.
Add delay between retries
For temporary failures, retrying immediately may hit the same problem again.
A system may wait before the next attempt.
For example:
- first retry after 1 second
- second retry after 2 seconds
- third retry after 4 seconds
This is called exponential backoff.
It gives the external service time to recover.
Respect retry instructions from the tool
Some services return information such as:
retry_after_seconds = 30
If available, the agent should respect that value rather than inventing its own retry timing.
This is especially common with rate limits.
Add jitter in distributed systems
If many agent workers fail at the same time and all retry at exactly the same interval, they can overload the service again.
A small random delay called jitter can spread retries over time.
This is useful in large distributed agent systems.
Do not blindly retry state-changing actions
Read-only operations are usually easier to retry safely.
For example:
get_order_status
can often be called again without side effects.
But actions such as:
- charge_card
- send_email
- create_order
- transfer_money
- deploy_service
may already have succeeded even if the response was lost.
Retrying blindly could perform the action twice.
Use idempotency for action tools
An idempotency key lets repeated attempts represent the same logical operation.
For example:
create_payment
- amount: 1000
- idempotency_key: payment_request_123
If the first request succeeded but the response was lost, a retry with the same key should not create a second payment.
This makes retries much safer.
Check the current state before repeating uncertain actions
When a tool times out after a state-changing operation, the agent may first verify whether the action already happened.
For example:
- create_order times out
- call get_order_by_request_id
- if the order exists, do not create it again
- if it does not exist, retry safely
This is better than assuming the first attempt failed.
Rate-limit failures need special handling
If the agent receives:
rate_limit_exceeded
it should not immediately repeat the same call.
Possible responses include:
- wait until the retry window
- reduce request frequency
- batch requests
- use an authorized alternative
- stop if the task cannot wait
Repeated immediate retries can extend the rate-limit problem.
Retry only when something has changed
A useful principle is:
Do not retry the exact same call unless there is a reason to believe the result may be different.
Something should change, such as:
- enough time has passed
- arguments were corrected
- credentials were refreshed
- service availability improved
- another dependency succeeded
Otherwise the retry is probably pointless.
Use fallbacks when repeated retries fail
If a primary tool continues failing, the agent may use an authorized fallback.
For example:
Primary search service: unavailable
Fallback: secondary search service
A fallback should still meet the task's correctness, security, and permission requirements.
Preserve retry history
The workflow should record:
- attempt number
- error code
- arguments used
- time of attempt
- whether arguments changed
- next retry decision
This helps prevent the agent from repeating the same unsuccessful action without learning from previous attempts.
Stop when retrying becomes unsafe or unhelpful
The agent should stop retrying when:
- the retry limit is reached
- the failure is non-retryable
- authorization is denied
- the action outcome is uncertain and duplication is risky
- the service remains unavailable
- the expected benefit is lower than the retry cost
At that point, it can return a clear failure, use a fallback, or request human help depending on the workflow.
A practical retry flow
A reliable retry decision can follow this sequence:
- Classify the error.
- Decide whether it is retryable.
- Correct inputs if needed.
- Check whether the action is safe to repeat.
- Use idempotency or status verification for state-changing actions.
- Apply backoff or retry-after timing.
- Retry only up to a fixed limit.
- Use a fallback or stop if attempts continue failing.
In short
An agent should retry failed tool calls selectively, not automatically.
Good retry behavior means understanding the error, fixing correctable problems, using bounded attempts and backoff, respecting rate limits, and protecting state-changing actions with idempotency or status checks before trying again.
Learning Sequence
AI Agents Curriculum
How can an agent choose between multiple similar tools?
Explore Related Questions
Deepen your understanding across related AI Agents topics.