[Blog](https://cohesivity.ai/blog)

Reliability & production

Published Jul 29, 2026·Updated Aug 30, 2026

![](https://cohesivity.ai/authors/anshu.webp)![](https://cohesivity.ai/authors/shouryamaan.webp)[Anshu](https://www.linkedin.com/in/aanshuaggrawal120/) and [Shouryamaan](https://www.linkedin.com/in/shouryamaanjain/)

# AI Agent Failure Recovery: Retries, Checkpoints, and Human Approval

[Read as Markdown](https://cohesivity.ai/blog/ai-agent-failure-recovery-retries-checkpoints-human-approval.md)

Failure

Retry

Checkpoint

Approved

AI agent failure recovery decides whether a failed step should stop, retry, reconcile, wait for approval, compensate, or resume from a checkpoint. The decision depends on the error class and whether an external effect may already have completed.

Automatic retries are safe only when the operation contract makes repetition safe. A timeout does not prove failure.

## Classify the failure before responding

| Failure                            | Default response                                      |
| ---------------------------------- | ----------------------------------------------------- |
| Invalid input or schema            | Stop and correct the request                          |
| Authentication or authorization    | Stop and request valid access                         |
| Policy denial                      | Stop or request the specified approval                |
| Rate limit with retry time         | Wait, then retry within the operation budget          |
| Transient read failure             | Retry with bounded backoff                            |
| Write timeout with unknown outcome | Reconcile before retrying                             |
| Permanent provider failure         | Fail or use a documented alternate path               |
| Worker crash                       | Resume from persisted state                           |
| Partial multi-system completion    | Continue, compensate, or escalate according to policy |

Expose stable error codes from tools. Do not ask the model to infer retry safety from prose such as “something went wrong.”

## Give one logical write one operation ID

Create an operation record before a consequential call. Store the action, tenant, resource, normalized input hash, idempotency key, state, attempts, provider reference, and result.

Reuse the same idempotency key for every retry of that logical effect. Reject reuse with different parameters. Stripe’s [idempotent request documentation](https://docs.stripe.com/api/idempotent%5Frequests) illustrates a server-side contract that returns the stored result for repeated keys. Its retention rules are provider-specific, so set your window from the longest realistic resume path.

If the provider has no idempotency support, your operation table prevents two local workers from intentionally starting the same action. It cannot settle a response lost after the provider acted. Add a provider lookup, webhook, or human reconciliation step.

## Checkpoint verified progress

Checkpoint after the system verifies an external effect, not after the model says it happened. Store provider identifiers or operation references. On resume, load the checkpoint and authoritative backend state before calling the model again.

The [durable execution guide](https://cohesivity.ai/blog/durable-execution-for-ai-agents) explains workflow history, deterministic replay, and persisted waits. Failure recovery adds the operational choice for each state.

## Assign one retry owner

HTTP clients, queues, workflow engines, model SDKs, tools, and providers may all retry. Choose one owner for each failure class and count every attempt under the same operation.

Set maximum attempts, elapsed time, backoff, and a terminal result. Stop on validation, authorization, and policy failures. For model calls, decide whether a retry uses the same prompt and tools or creates a new decision. Record that distinction because it changes the evaluation.

## Reconcile unknown outcomes

When a write times out:

1. mark the operation `unknown`, not `failed`;
2. query by idempotency key, provider reference, or expected business state;
3. mark it completed if the effect exists;
4. retry only if the provider confirms it did not occur;
5. request human review when neither result can be established.

Do not hide an unknown state behind a success message. The user may need to avoid repeating the request while reconciliation continues.

## Put approval before a high-impact attempt

Approval should bind the action, resource, parameters, actor, and expiry. Recheck authorization when execution resumes. A broad approval such as “continue” should not cover modified payment or deletion parameters.

Railway’s [agent deletion incident](https://blog.railway.com/p/your-ai-wants-to-nuke-your-database) led it to align API deletion with a 48-hour soft-delete period. Reversible effects reduce recovery pressure, but they still require scoped identity and audit records.

## Distinguish cancellation from compensation

Cancellation prevents future work. It cannot undo a completed email, payment, or external publication. Compensation is a separate action such as voiding an invoice or restoring a soft-deleted resource.

Compensations need their own authorization, idempotency, operation record, and failure path. Avoid describing them as automatic rollback when multiple external systems lack a shared transaction.

## Write a runbook a human can execute

For each high-impact workflow, document:

- how to stop new runs and active workers;
- which credential to revoke;
- how to find tasks and operations in scope;
- how to classify unknown outcomes;
- which retries are safe;
- which effects can be compensated;
- who approves recovery and how completion is verified.

Link the runbook to trace and operation queries. The [observability guide](https://cohesivity.ai/blog/ai-agent-observability-what-to-monitor) lists the identifiers needed to follow an incident end to end.

## Practice failure between the lines

Inject failures before a call, after the provider receives it, after it succeeds but before the response arrives, after the checkpoint, during approval, and during cancellation. Resume on a fresh worker with no local state. Verify the effect count and final business state.

The prompt below designs the most revealing drill without touching production. If the runbook cannot distinguish “failed” from “may have succeeded,” fix that branch before increasing autonomy.

or send it to[Claude Code](https://claude.ai/new?q=Inspect+this+repository+and+choose+an+AI+agent+workflow+with+a+consequential+external+write.+Do+not+touch+production+or+call+external+services.+Map+its+validation%2C+authorization%2C+rate-limit%2C+timeout%2C+provider%2C+and+policy+failure+paths.+Identify+the+idempotency+key%2C+checkpoint%2C+operation+record%2C+retry+owner%2C+approval+boundary%2C+cancellation+behavior%2C+reconciliation+query%2C+and+compensation.+Design+an+isolated+drill+that+loses+the+response+after+the+write+may+have+succeeded%2C+restarts+on+a+fresh+worker%2C+and+proves+the+effect+occurs+at+most+once.+Report+every+undefined+recovery+decision+before+suggesting+changes. "Send to Claude")[Cursor](https://cursor.com/link/prompt?text=Inspect+this+repository+and+choose+an+AI+agent+workflow+with+a+consequential+external+write.+Do+not+touch+production+or+call+external+services.+Map+its+validation%2C+authorization%2C+rate-limit%2C+timeout%2C+provider%2C+and+policy+failure+paths.+Identify+the+idempotency+key%2C+checkpoint%2C+operation+record%2C+retry+owner%2C+approval+boundary%2C+cancellation+behavior%2C+reconciliation+query%2C+and+compensation.+Design+an+isolated+drill+that+loses+the+response+after+the+write+may+have+succeeded%2C+restarts+on+a+fresh+worker%2C+and+proves+the+effect+occurs+at+most+once.+Report+every+undefined+recovery+decision+before+suggesting+changes. "Send to Cursor")[Codex](https://chatgpt.com/codex?prompt=Inspect+this+repository+and+choose+an+AI+agent+workflow+with+a+consequential+external+write.+Do+not+touch+production+or+call+external+services.+Map+its+validation%2C+authorization%2C+rate-limit%2C+timeout%2C+provider%2C+and+policy+failure+paths.+Identify+the+idempotency+key%2C+checkpoint%2C+operation+record%2C+retry+owner%2C+approval+boundary%2C+cancellation+behavior%2C+reconciliation+query%2C+and+compensation.+Design+an+isolated+drill+that+loses+the+response+after+the+write+may+have+succeeded%2C+restarts+on+a+fresh+worker%2C+and+proves+the+effect+occurs+at+most+once.+Report+every+undefined+recovery+decision+before+suggesting+changes. "Send to Codex")[opencode](https://opencode.ai/?q=Inspect+this+repository+and+choose+an+AI+agent+workflow+with+a+consequential+external+write.+Do+not+touch+production+or+call+external+services.+Map+its+validation%2C+authorization%2C+rate-limit%2C+timeout%2C+provider%2C+and+policy+failure+paths.+Identify+the+idempotency+key%2C+checkpoint%2C+operation+record%2C+retry+owner%2C+approval+boundary%2C+cancellation+behavior%2C+reconciliation+query%2C+and+compensation.+Design+an+isolated+drill+that+loses+the+response+after+the+write+may+have+succeeded%2C+restarts+on+a+fresh+worker%2C+and+proves+the+effect+occurs+at+most+once.+Report+every+undefined+recovery+decision+before+suggesting+changes. "Send to OpenCode")
