The most dangerous agent state is worse than "failed." It is failed halfway.

Three of seven records updated. The notification sent but the database write lost. A workflow abandoned mid-transaction with no record of how far it got. A clean failure you can simply rerun; a partial one you have to untangle by hand, usually while someone waits.

Demo agents are built for the happy path. Production agents are built for the Tuesday when the API times out at step four.

The recovery vocabulary

Five distinct mechanisms, each answering a different failure class. A system with only one of them has recovery for that class and nothing else:

  • Retry: for transient failures only. With exponential backoff, jitter and a hard cap. Uncapped retries against a struggling dependency turn your outage into their outage. Any retried write needs an idempotency key, or a call that timed out after succeeding gets applied twice.
  • Fallback: a simpler tool, an older data source, a degraded answer that is honest about being degraded.
  • Checkpoint: durable progress markers, so resuming means continuing rather than restarting. This is what turns "failed halfway" from an incident into an inconvenience.
  • Rollback: compensating actions for anything externally visible. If step 5 fails, steps 1 through 4 need an undo story, and "we'll fix it manually" is that story until you write a better one. Some actions have no compensation, such as a sent email, so run them last.
  • Escalate: hand to a human with state attached. "Task failed" is a notification. An escalation includes what was attempted, what succeeded, what is now half-done, and what decision is needed.

The distinction that matters most is that retry is for transient failures, not for wrong assumptions. An agent that retries a bad plan three times has just failed three times more expensively, and the trace will show three reasonable-looking attempts. Classify by error. Timeouts, throttling and server errors are worth retrying, while a validation error means the input or the plan is wrong.

Test the paths deliberately

This is the discipline that separates teams who have recovery from teams who have recovery code.

Kill the API mid-task in staging. Return a malformed response. Time out the third of five tool calls. Then watch exactly what the agent does.

Whatever it did just now is what it will do in production, at 2am, on a real customer's request. If nothing in the loop checks each step's result, the first test shows the agent cheerfully continuing as though the failed step had succeeded.

Then take your last incident and mark which of the five paths it exercised, and which it needed but did not have. A path that has never run in a test or an incident is an assumption; put it in the next fault-injection run before you rely on it.

About this explainer

Format
Explainer
Level
Practitioner
Read
2 min read
Published
Jun 29, 2026

Short mental models: one idea, why it matters, what to do about it.

Article · · 2 min read

Read post-mortems, not tutorials

Tutorials teach one tool's happy path. Post-mortems teach how systems fail, and that carries over to every stack you will work on.