Xavier Fok
← All writing

· 6 min read

What an agent should never be allowed to retry

Agent retry limits aren't optional polish. A concrete look at which failed agent actions are safe to retry automatically and which ones need a human in the loop first.

The first time I let an agent retry a failed step without thinking it through, it sent the same outreach email to a partner four times in one morning. Nothing broke. No error in any log. The agent just did what I told it to do: if the step fails, try again. The problem was that the step hadn’t actually failed. It had succeeded, and then the confirmation step timed out, so the agent assumed the whole thing needed to run again.

That’s the core issue with retries in agent systems. A retry is a bet that the first attempt didn’t happen, or didn’t matter. Most of the time that bet is fine. Sometimes it isn’t, and when it isn’t, the agent doesn’t know the difference unless you build that knowledge in yourself.

Why retries feel safer than they actually are

Retrying is the default instinct in software because most of the operations we grew up automating are read operations or operations with natural idempotency. Fetch a page again, it’s fine. Query a database again, it’s fine. Re-render a frame that failed to encode, it’s fine. Those operations don’t change state in a way that stacks up if you do them twice.

Agents blur this because a single “step” in an agent’s plan often bundles several real-world actions together: check a condition, call a tool, write a result, move to the next step. If the failure happens after the tool call but before the write, a naive retry repeats the tool call. If that tool call sends a message, moves money, or deletes something, repeating it isn’t a retry anymore. It’s a second, unwanted action wearing a retry’s clothes.

Actions that should never retry automatically

Anything that sends something to a human. Email, Slack, WhatsApp, Telegram, a support ticket reply. If the agent isn’t sure whether the first send went out, the safe move is to check the outbox or the delivery log before sending again, not to fire another copy and let the recipient sort it out. A duplicate message to a partner or customer reads as sloppy at best and as spam at worst.

Anything that changes money or billing state. Charging a card, issuing a refund, applying a coupon, changing a subscription tier. These need an idempotency key tied to the original request, not a blind “try the charge again.” Payment providers that support idempotency keys exist specifically because this problem is common enough to need a standard fix, not a one-off patch.

Anything destructive. Deleting a file, dropping a database row, force-pushing over a branch, wiping a device, overwriting a config that something else depends on. A destructive action that partially failed can leave the system in a state where retrying doesn’t repeat the original action, it does something different and worse, because the starting conditions already changed.

Anything that spawns another agent or another instance of itself. If a supervising process retries a failed sub-agent run by launching a new one without confirming the old one actually exited, you can end up with two processes competing for the same resource, writing to the same file, or hitting the same rate-limited API at once. This is an easy way to turn one stuck job into a pile of orphaned processes that nobody notices until something runs out of memory or a quota gets burned.

A multi-step chain re-run from the start. If step 4 of a 6-step plan fails, the fix is almost never “run steps 1 through 6 again.” Steps 1 through 3 already happened. Re-running them risks duplicating whatever they did, and even when it doesn’t duplicate anything, it wastes time and tokens redoing work that was already fine. The agent needs to resume from the failure point, which means the plan needs checkpoints, not just a start and an end.

Auth failures and rate limits. This one surprises people. If a call fails with a 401 or a 429, the instinct is to retry. But blindly retrying an auth failure doesn’t fix an expired token, it just repeats the failure, and enough repeated failures in a short window can look like credential stuffing or abuse to whatever system you’re calling. Repeated retries against a rate limit make the problem worse, not better, because you’re adding load to a system that already told you to back off. Both of these need a different response than “try again”: refresh the token, or wait and back off on a schedule, not a tight loop.

The test that actually matters

Before you let any step retry automatically, ask one question: if the first attempt actually succeeded, what happens when the agent does it again? If the answer is “nothing changes, it’s the same result,” it’s safe to retry. If the answer is “something happens twice,” it needs a guard before it ever gets a second attempt.

This is the same idempotency question backend engineers have asked for years about API requests, applied to agent actions instead of HTTP calls. The agent world just makes it easier to forget, because a tool call inside an agent’s reasoning loop doesn’t look like a network request with a status code. It looks like a thought the agent had. It’s easy to assume that if the thought gets retried, no harm is done, when the tool call underneath it did something real.

What to build instead of a blind retry

For anything read-only or naturally idempotent, a capped retry with backoff is genuinely fine. Two or three attempts with increasing delay between them, then give up and log it. This covers most tool calls that fetch data, check status, or run a computation with no side effects.

For anything with a side effect, the fix isn’t “never retry,” it’s “retry safely.” That usually means one of a few patterns:

An idempotency key attached to the original request, so if the same request comes through twice, the receiving system recognizes it and returns the original result instead of doing the action again. This only works if the system on the other end supports it, so it’s worth checking before you assume a retry is safe.

A check-before-act step, where the agent looks for evidence the action already happened before attempting it again. Did the email already land in the sent log? Does the record already exist? This adds a call, but it’s cheap compared to the cost of a duplicate.

A dead-letter path, where after one failed attempt on anything risky, the agent stops and logs the failure for a human to review instead of trying again on its own. This is less satisfying than full automation, but for the categories above, a human glancing at a short queue of failed actions once a day is a lot cheaper than untangling what a silent retry loop did overnight.

Retries can also hide the real problem

There’s a second cost to retries that has nothing to do with duplication: they can bury a failure that a human needed to see. If a step keeps failing and the agent just quietly keeps trying, you can end up with a job that “completes” hours late after ten silent retries, when the real story is that something upstream broke and needed attention immediately. A capped retry that then escalates loudly is doing its job. An uncapped retry that eventually succeeds by luck is teaching you nothing about the actual failure, and it’ll happen again.

Retry limits aren’t about distrust of the agent’s intelligence. They’re about the fact that an agent, like any piece of software, can’t always tell the difference between “this didn’t happen yet” and “this happened but I lost track of it.” Until it can, that judgment call belongs to whoever built the system, applied step by step, action by action, before the agent ever gets to press retry on its own.

If you’re setting up agents to run real tasks and want to see how this plays out with actual tools and actual failures, more of this kind of breakdown lives on the xavierfok.com home page.

Get new guides and videos first — join the Telegram channel.

Keep reading