Chevron left
blog

Long-Running Agents: Durable State and Safe Recovery

Persist decisions, approvals and external operation outcomes separately. Define replay boundaries, duplicate handling, timeouts and operator recovery for interrupted tasks.
August 28, 2026
Articles
Diagram of four agent steps checkpointed on one continuous state spine with a replay loop between two steps.

Table of Contents

Reviewed and updated November 13, 2026.

In short: A long-running agent should persist its decisions and external effects separately from conversation history, record a stable operation key before every write, and resume only from verified state. When an outcome is unknown after a restart, it should reconcile or pause for an operator rather than submit again.

A long-running agent needs to know what has already happened when its process stops. Conversation history alone is not a reliable action ledger. Before adding more memory, decide which facts, approvals and external effects must survive a restart.

Durable execution records progress so an interrupted workflow can resume. Temporal's Event History documentation describes replay from a persisted event log. An agent still needs a boundary between replaying recorded decisions and making a new model or tool call.

Persist decisions and effects separately

Record the task identifier, current state, selected model and prompt version, tool arguments, observed results and relevant source versions. Treat a model response as a recorded result when replay must reproduce an earlier decision. Re-running generation during recovery can produce a different plan.

For side effects, keep the logical operation identifier, attempted action, approval record and provider receipt or verified state. Distinguish planned, approved, executing, succeeded, failed and unknown outcomes. “Unknown” is important when the external service might have completed an action but the response was lost.

An illustrative replacement workflow

Consider an agent that prepares and submits a replacement order after review. This is a proposed recovery design, not a report of a running system.

  1. Save the proposed order and the specific version approved by a reviewer.
  2. Create a stable operation key for that submission and persist it before calling the order API.
  3. Call an endpoint that enforces duplicate handling for the key, then save the returned order identifier.
  4. If the connection drops, query the order status using the operation key or another supported reconciliation mechanism.
  5. Resume from verified state. If the outcome cannot be established safely, pause for an operator instead of submitting again blindly.

Temporal's Activity guidance explains that retries can repeat an external operation after a worker crashes and that idempotency keys must be enforced by the receiving service. A saved checkpoint does not provide that external guarantee.

Bound retries and waiting

Set per-operation timeouts, maximum retry behavior and a task deadline. Retry transient transport failures differently from permission denials, invalid arguments or a changed business state. Record why a task is waiting and when an operator should inspect it.

Approvals also expire or become invalid when their target changes. Recheck the current resource version, user permission and approval conditions before continuing. A restart is not permission to execute an obsolete proposal.

Choose the amount of durability the work needs

A short read-only query may only need ordinary request handling. A scheduled batch job can use a queue and a simple status record. Multi-step tasks with external changes or human waits may justify a durable workflow engine. The application still owns state schemas, migrations, retention, cancellation and operator tools.

Test interruption before a call, after external completion but before recording it, while waiting for approval and during deployment of a new workflow version. Verify that cancellation prevents further authorized actions and that an operator can inspect and resume the correct task.

Common questions

What state does a long-running AI agent need to persist to survive a restart? It should record the task identifier, current state, selected model and prompt version, tool arguments, observed results and relevant source versions. For side effects, it should also keep the logical operation identifier, attempted action, approval record and provider receipt or verified state. Conversation history alone is not a reliable action ledger, so these facts need to be stored as explicit records the workflow can resume from.

How do you stop a recovering AI agent from repeating an external action? Create a stable operation key for each submission and persist it before calling the external API. Call an endpoint that enforces duplicate handling for that key, then save the returned identifier. If the connection drops, query status using the key or another supported reconciliation method. A saved checkpoint does not guarantee idempotency; the receiving service must enforce it, and an unresolved outcome should pause for an operator.

When does an AI agent workflow need a durable workflow engine? It depends on the work. A short read-only query may only need ordinary request handling, and a scheduled batch job can use a queue and a simple status record. Multi-step tasks with external changes or human approval waits may justify a durable workflow engine. Even then, the application still owns state schemas, migrations, retention, cancellation and the operator tools used to inspect and resume tasks.

Free AI Economics & Operations Kit

Download the 24-Month AI Operating Cost, Routing & Launch-Gate Workbook

Includes the editable 24-Month Workflow Compilation & 5-Layer TCO Calculator (.xlsx), the 30-Control Release & Operations Checklist (.pdf), and the Model Sunset Register (.csv).

Preview of the ALLTIPLY 24-Month AI Operating Cost and Release Readiness Kit

See AI automation for work that spans systems and human review. Book a call to discuss the steps, side effects and recovery behavior the workflow requires.