Agent Orchestration

Durable AI Agent Workflows: Checkpoints, Replay, and Recovery

Design durable AI agent workflows with checkpoints, recorded decisions, safe retries, and recovery paths that handle crashes without duplicating actions.

· · 8 min read

Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.

A durable AI agent workflow can continue after a worker crashes without treating the entire task as a fresh conversation. The difficult part is deciding what must be remembered, which operations may run again, and what to do when an external action succeeded but its acknowledgement disappeared.

Durability therefore needs an execution contract. Saving chat messages is useful, but a transcript alone does not tell the runtime whether an invoice was posted, which model response authorized the next step, or which approval is still valid.

Checkpoints and event replay solve different recovery problems

A checkpoint captures execution state at a defined boundary. LangGraph organizes checkpoints by thread and saves full graph state at super-step boundaries; it can also preserve successful node writes within a partially failed super-step. That last detail matters when parallel work has mixed outcomes. LangGraph checkpointers

Event-history replay reconstructs execution by running orchestration code against recorded events. Temporal reuses recorded activity results rather than repeating completed activities during workflow replay. A model invocation belongs outside deterministic workflow logic, in an activity whose result enters history. Temporal workflow replay

These approaches are not interchangeable promises. Ask your chosen runtime precisely where persistence happens, what survives a process loss, and which code executes again. Treat words such as resume, retry, replay, and fork as separate operations in your application API.

Operation Intended meaning Main question
Resume Continue unfinished execution Which completed results remain authoritative?
Retry Attempt a failed unit again Can another attempt duplicate an effect?
Replay Reconstruct or inspect a historical path Are external calls suppressed or re-executed?
Fork Create an alternative continuation Is this branch authorized to mutate real systems?

Define those meanings before building recovery buttons in an admin dashboard. An operator clicking replay to inspect a failure should not accidentally send the customer another message.

Persist decisions rather than hoping to regenerate them

An LLM call can produce a different answer after a restart. A low sampling temperature is not a substitute for recording the actual response used by an execution. For recovery, the important artifact is the accepted decision, including its validated arguments and evidence references.

An illustrative decision record might contain:

{
  "run_id": "run-742",
  "step_id": "classify-invoice",
  "decision_version": 1,
  "input_digest": "sha256:...",
  "model_config_ref": "invoice-classifier-v4",
  "accepted_output": {"route": "manual_review"},
  "evidence_refs": ["invoice:308:version:2"],
  "validation_status": "passed"
}

This is a design sketch, not a framework schema. Store enough information to explain the transition without placing every token, secret, or document body in orchestration history. Large artifacts can live in controlled object storage, referenced by immutable identifiers and content digests.

If the business requests a new interpretation, create a new decision version or branch. Do not silently replace the old result while preserving the original execution identity. The distinction keeps historical explanation separate from current reasoning.

Keep orchestration deterministic and external work explicit

Replay-based orchestrators need stable control flow for recorded history. Microsoft documents hazards including ordinary clock reads, random UUID generation, direct network I/O, and changing environment variables inside orchestrator code. Use the runtime's replay-safe APIs or move such work into activities. Durable orchestrator constraints

For an agent, apply that boundary to retrieval and policy lookup as well as model calls. A search performed today might return different documents tomorrow. If a stored model decision depended on yesterday's evidence, its recovery path should not quietly mix that decision with a newly retrieved policy.

A practical separation is:

  • The orchestration layer selects the next recorded or pending step, checks budgets, and handles events.
  • Activities call models, search indexes, databases, and business tools.
  • Validation turns raw activity responses into accepted state transitions.
  • An action ledger records intended and observed external mutations.

This design makes the agent's state machine explicit. It also gives reviewers a concrete place to ask whether a transition is allowed, instead of embedding every rule in a prompt.

A hypothetical invoice workflow and its crash windows

Consider an illustrative workflow that extracts an invoice, matches a purchase order, obtains approval, posts an accounting entry, and notifies an operator. No performance or reliability results are claimed for this example.

At admission, assign a stable run identity and persist the source document version. Extraction produces structured fields plus evidence locations. Matching stores the purchase-order revision it inspected. Approval binds to a digest of the proposed accounting action, rather than to an open-ended instruction to continue.

Before posting, reserve an action identity such as invoice-308:post:v1, bind it to the exact payload digest, and persist it. Then call the accounting API using that identity if the API supports idempotent requests.

Now examine the failure windows:

  1. Crash before the call: recovery finds an intended but unattempted action. It can attempt the same operation after rechecking authorization.
  2. Crash during the call: the outcome is unknown. Recovery queries the accounting system by operation identity or uses its documented deduplication mechanism.
  3. Crash after remote commit but before local acknowledgement: this remains unknown locally; it is not proof that posting failed.
  4. Crash after the result is durably recorded: recovery uses the recorded result and moves to notification.

Temporal explicitly distinguishes completed activities reused during replay from activities whose result never reached the service; the latter can be retried. Its documentation recommends idempotent activities because external effects can otherwise repeat. Temporal activity idempotency

The durable runtime does not atomically commit your accounting system and its own history. Action-level idempotency and reconciliation close that application-level gap. If the external API offers neither lookup nor deduplication, route ambiguous results to an operator rather than guessing.

Choose checkpoint boundaries around meaningful progress

A useful checkpoint separates completed, reusable work from work that can safely be repeated. In the invoice example, extraction and purchase-order matching are separate units because the second may fail without making the first worthless.

Avoid an oversized node that extracts, approves, posts, and sends email before returning. A crash near its end creates several uncertain effects. Conversely, checkpointing every minor string transformation may inflate storage and recovery overhead without reducing meaningful risk.

LangGraph's fault-tolerance guidance notes that checkpoint boundaries do not include arbitrary side effects performed inside a node. It recommends stable idempotency keys and treating lost acknowledgements as unknown outcomes. If a generated key must survive a crash before an action, its preceding checkpoint must actually be durable. LangGraph fault tolerance

For this design, place boundaries after an accepted decision, before an externally visible mutation, and after its reconciled result. Measure the added storage latency against the cost of repeating work. A memory-only checkpointer is not a process-restart recovery strategy; LangGraph's persistence guide explicitly warns that its in-memory savers lose state on restart. LangGraph persistence

Recovery must respect time, authorization, and versions

A persisted approval is not necessarily valid forever. While the workflow sleeps, the customer may cancel, a source document may change, or a user may lose permission. Preserve the historical approval record, then separately evaluate whether its scope and expiry still permit the pending action.

A reasonable invoice policy would require fresh approval if the amount, destination account, or purchase-order revision changes. That is a proposed business rule, not a universal framework behavior. Approval-gate design should make these invalidation conditions visible to the operator.

Software upgrades introduce another recovery dimension. Store the state schema and workflow version with each run. Before deploying new control flow, replay representative historical executions in an isolated environment where mutation tools cannot reach production. Have a migration or old-worker strategy for runs the new version cannot interpret.

Validate durability with deliberate failures

Build a fault-injection matrix rather than testing only successful restarts:

  • Kill a worker after a model response but before its acceptance record; determine whether resampling is expected and bounded.
  • Kill it after remote posting but before acknowledgement; assert one accounting entry and a reconciled local result.
  • Fail one parallel branch; verify which successful branches the runtime preserves.
  • Resume an expired approval; assert that execution stops before mutation.
  • Resume old state with new worker code; detect incompatibility before tools execute.
  • Lose the persistence connection; verify the application does not claim durable success prematurely.

Track recovery age, unresolved action outcomes, repeated attempts, checkpoint failures, and operator interventions. A durable workflow can still be stuck indefinitely. Put deadlines and escalation ownership on states that require external resolution.

Frequently asked questions

Does durable execution guarantee exactly one external action?

No. A recorded completed step may be reused during replay, but an action can succeed remotely before its result is recorded locally. Safe retries require the external system's deduplication contract or application reconciliation.

Should recovery ask the model to make the decision again?

Reuse an accepted recorded decision when continuing the same execution. Re-evaluate when business rules explicitly demand fresh evidence or authorization, and record that as a new decision rather than rewriting history.

Do short agents need a workflow engine?

Not always. A short read-only request may need only timeouts and a bounded retry. Durable orchestration becomes more valuable when tasks cross process lifetimes, await people, incur expensive intermediate work, or mutate several systems. The decision should follow the failure-recovery requirements, not the number of agents.

Source reference list

AI Agent Orchestration
Durable Execution
Workflow Recovery
Agent Reliability