How to Recover From Failed AI Executions
Classify the failure before you retry, make steps idempotent, and resume from a checkpoint. A runbook for the seven failure modes that actually occur.
Direct Answer (Quick Summary)
Recover failed AI executions by classifying the failure before retrying, keeping every step idempotent, and resuming from the last checkpoint instead of restarting the run. Most failed runs are not lost work. They are a run that stopped at a step a person or a system could have finished in seconds, usually because of an expired credential, a rate limit, a changed tool schema or an approval that timed out.
Key Takeaways
- Classify the failure before retrying, because a rate limit and a bad input need opposite responses.
- Idempotent steps make retry safe; non-idempotent writes are where a retry turns one failure into two.
- Checkpointing turns a restart into a resume, which is the difference between minutes and hours of rework.
- Approval timeouts are a design failure, so they need an expiry policy and an owner rather than more retries.
- Changed tool schemas are detected by validating arguments before execution, not by reading the error afterwards.
- Budget exhaustion is a stop condition that should preserve partial work and escalate to a human.
- Every recovered run should leave a note in the log explaining what failed and what resumed it.
Recover failed AI executions by classifying the failure before retrying, making every step idempotent, and resuming from the last checkpoint rather than restarting the whole run. Most failed runs are not lost work. They are a run that stopped at a step a person or a system could have finished in seconds.
Classify before you retry
Blind retries are the most common way a small failure becomes an incident. The classification takes thirty seconds and determines the correct response.
| Failure | Typical signal | Correct response |
|---|---|---|
| Expired credential | Auth error on a single tool | Fix the credential, resume from checkpoint |
| Rate limit | 429 or throttling, repeats across runs | Back off, widen the window, do not retry tightly |
| Rate-limited budget | Ceiling hit mid-run | Stop, preserve state, escalate to a human |
| Bad input | One record fails schema or parsing | Route that record to an exception queue |
| Changed tool schema | Validation error on an argument that used to work | Repair the connection, then replay the affected steps |
| Model error | Reasoning produced an unusable step | Re-plan once, then hand to a human |
| Approval timeout | Gate waited past its window | Expire to a named owner with the partial work attached |
Two of these deserve a note. A changed tool schema is the one teams discover months later: nothing was wrong with the AI, a field was renamed upstream. The defence is validating arguments against the tool schema before execution, which is what MCP-style connections give you. An approval timeout is not a runtime error at all, it is a missing policy: nobody decided how long a gate waits or who inherits it. Gate design is covered in how to build approval-based AI workflows.
The failure mode: the retry storm
Retries are the correct answer to a narrow set of failures and a catastrophic answer to the rest. The storm has a recognisable shape, and it is worth naming because each stage of it looks like reasonable behaviour in isolation.
- A step fails transiently. A 429, a timeout, a socket reset.
- The retry policy fires. Three attempts, no delay, because that is the default in most queues.
- The workflow has no checkpoint at step boundaries, so a retry replays from the last durable state — which may be step one.
- The replay re-sends the earlier outbound calls. They succeed this time, because the rate limit has passed.
- The employee now believes the workflow is further behind than it is, and the next run starts with a stale count.
- The budget ceiling is hit while the team is still looking at the original 429.
The damage is not the failed run. It is duplicate outbound effects, a corrupted count in Memory, and a spend number nobody can reconcile to an outcome.
The arithmetic: a 12-step workflow replayed from step one, at three automatic attempts per step, is up to 36 step executions to finish work that needed 12. At a per-run budget set for one pass, the run cannot complete at all — the ceiling is reached before the work is done, and the failure presents as a budget problem rather than the retry problem it is.
Make steps idempotent or do not retry them
An idempotent step produces the same result whether it runs once or three times. Reads are naturally idempotent. Most writes are not.
Before enabling retries on a write step, check three things:
- Does the call carry a client-generated idempotency key, so a repeat is recognised as a repeat?
- Is there a lookup that confirms the write already happened, so the retry can skip rather than duplicate?
- Is the consequence of a duplicate bounded, so that even a missed check is recoverable by a person?
If all three fail, mark the step non-retryable and route it through the approval gate. A duplicate refund is a real incident; a stalled queue with a person waiting is an inconvenience. That asymmetry is why preventing AI employees from taking unauthorized actions includes idempotency, not just permissions.
Classify every step in a live workflow by writing down what a duplicate would cost. "Nothing" means retryable. "A duplicate email" means retryable with a key. Anything involving money, a deleted record or an external commitment is non-retryable until someone adds a key or a lookup.
Checkpoint and resume
A checkpoint is a record of what completed, in a form the next run can read: the record identifiers processed, the step boundary, and the state each step left behind.
Without checkpoints, recovery means replaying the workflow. With them, recovery means continuing it. On a five-day onboarding workflow that is the difference between losing an afternoon and losing the run.
A useful discipline is to checkpoint at step boundaries rather than mid-step. Mid-step checkpoints are only worth the complexity when a single step is long-running and non-idempotent, which is a case where the safer answer is usually to break the step in two.
The checkpoint has to be written by the same mechanism that decides what runs next, or the two drift and resume becomes a guess. Where multi-step execution gets its structure in the first place is how AI employees handle multi-step work.
A worked recovery: 42 records, four resumes
A collections workflow dunning overdue invoices. Monday it processes 42 records; record 29 fails and the run halts.
09:14 — Run halts. Steps 1–28 completed; step 29 returned a validation error on an argument that worked last week. Classification: changed tool schema — amount_due was renamed upstream to amount_due_minor. This is the one failure where retrying immediately is guaranteed to fail again, because nothing has changed yet.
09:20 — Fix the connection, not the run. Update the tool definition and re-validate. Roughly three minutes. Nothing about the run was wrong.
09:24 — Resume, not restart. The checkpoint says records_processed: C-10401..C-10428, so the run continues at 29. Twenty-eight invoices are not re-sent and 28 contacts receive no duplicate dunning email.
09:31 — One record is genuinely bad. C-10429 fails validation again after the schema fix, this time because its currency field is null. Classification: bad input. It goes to the exception queue and the run continues — treating one malformed row as a system failure would take forty-one valid ones down with it.
09:33 — Run completes. 41 processed, 1 to exceptions, cost and duration recorded against the outcome.
Total elapsed recovery: 19 minutes, one schema repair, zero duplicate customer contacts. Handled by restarting instead, the same incident would have re-sent 28 dunning emails. That difference comes almost entirely from the checkpoint.
A runbook
- Read the trace, not the error message alone. Find the last step that completed and the first one that did not, using the trace shape in AI observability for AI employees.
- Classify the failure against the table above.
- Check whether the step is idempotent. If it is not, do not retry it yet.
- Fix the cause: rotate the credential, widen the rate window, repair the schema, resolve the gate.
- Resume from the last checkpoint with a fresh budget allocation for the remaining steps only.
- Watch the next two steps closely. A fix that works once is not a fix.
- Log the recovery: what failed, why, what resumed it, and how long it took.
Step seven is what turns incident response into improvement. Without it you are handling the same failure twice next month. How to monitor AI employee executions is where the live view of steps 6 and 7 lives.
Design the failures you can live with
The most effective reliability work happens before a failure. Every workflow should state up front which failures retry, which escalate, and which are permanent. That statement is usually one page and is more valuable than any retry setting. How to design reliable AI workflows covers that step, and how to design AI employee workflows covers the surrounding structure.
Approval gates deserve one more sentence because they are the most commonly misconfigured part of a run. A gate with no timeout is an outage waiting for a holiday. A gate with no owner is a queue that grows until someone notices by the backlog.
When a human is mandatory
Some recoveries must not be automated, and the distinction is about consequence rather than difficulty.
| Situation | Who finishes it | Why |
|---|---|---|
| Credential expired, dependency healthy | Operator, then resume | Mechanical, no judgement |
| Tool schema changed | Whoever owns that integration | The fix is outside the workflow |
| One record fails validation | Exception queue, then continue | Scope is bounded and known |
| Model produced an unusable plan twice | Human | The plan is wrong, not the attempt |
| Budget ceiling reached | Named owner | Spend decisions are not the employee's |
| A write would duplicate and is not keyed | Human, every time | The consequence is unbounded by design |
The last row is the rule worth memorising: if you cannot make a write idempotent, a human approves it. When should humans approve AI actions argues the boundary from the other direction.
How to apply this
Take the last three failed runs in your system and classify each one using the table. If two of them share a cause, that cause is your reliability backlog, and it is usually a credential, a schema or an approval policy rather than the model.
Then make one change: mark every write step in a live workflow as idempotent or non-retryable, and record that choice in the workflow definition. Nothing else on this list improves recovery as much, because it is what makes a retry safe in the first place.
Sources and further reading
- Temporal documentation: durable execution and retries for long-running work.
- Docker Engine security: what container isolation does and does not provide.
- Anthropic: Building Effective Agents: workflow and agent patterns from production use.
Frequently Asked Questions
Should we retry a failed AI run or start it again?
Resume from the last checkpoint rather than replaying, and only retry steps that are idempotent. Restarting loses completed work and, on non-idempotent writes, can duplicate it. The full procedure is in how to recover from failed AI executions, with the trace format in AI observability for AI employees.
What does it mean for a step to be idempotent?
Running it twice produces the same result as running it once, so a retry is harmless. Reads are usually idempotent. Writes need an idempotency key, a lookup that detects an already-completed write, or a bounded consequence if both fail, which is why that check belongs in the retry design.
Why did our AI employee fail after working fine for weeks?
Usually a dependency changed underneath it: an expired credential, a renamed field in an upstream API, a new rate limit, or a schema change on a tool. Validate arguments against the tool schema before execution so you catch this at call time rather than discovering it as an unexplained failure weeks later.
How should we handle approval requests that nobody answers?
Give every gate a timeout and a named owner, and on expiry escalate to that owner with the partial work attached rather than silently failing or auto-approving. A gate with no timeout becomes an outage over a holiday, and a gate with no owner becomes a backlog nobody watches.
Is it worth logging every failed run permanently?
At least the failing step, its inputs and its cause, yes. Recovery quality depends on being able to tell whether a failure was a credential, a schema, an input or a plan, and that is impossible from a status code. Sampling successes is fine; sampling errors removes the only records you need.
What is an idempotency key and do we need one?
It is a client-generated identifier sent with a write so the service recognises a repeated request and returns the original result instead of acting twice. You need one wherever a retry could duplicate a real effect: charges, outbound messages, record creation. If the API does not support keys, use a lookup that confirms the write already happened, or mark the step non-retryable.
Related reading
- Prove Your End-of-Day Batch Recovers: Crash-Testing a COBOL Batch
- Why Outcomes Matter More Than Prompts
- How to Design Reliable AI Workflows That Do Not Drift
- AI Workflow Observability: What to Trace, Alert, and Fix
- How to Monitor AI Employee Executions End to End
- How to Design AI Employee Workflows That Actually Work
- How to Prevent AI Employees From Taking Unauthorized Actions