Durable and Asynchronous Agent Work › Durable Progress Across Restarts

Michael BrenndoerferDecember 1, 20263 min read
Language AI HandbookAll chapters
Part 49 of 67Long-Horizon Agents and Interoperability
Chapter 376Durable and Asynchronous Agent Work › Durable Progress Across Restarts
Reading section 2 of 15 · Durable Progress Across Restarts · 3 minSection 2 of 15 · 3 min

Section 2 of 15 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

If your application keeps its plan only in process memory, another worker cannot recover it after a restart. A long task can lose a draft or repeat calls when its worker disappears. A persisted trace helps a replacement worker recover committed progress. These durations and counts are illustrations, and the notebook runs locally without calling any models or services.

  • Make 30–80 model calls.
  • Fetch 200 web pages, some slow or failing with 3-retry logic.
  • Take 5–40 minutes of wall-clock time.
  • Cost real money per model call.

If the container that's running it gets preempted (spot instances, deploys, OOM killers, kernel OOM, user closing the browser), everything in memory evaporates. Without durability you get one of two outcomes: silent loss (the task disappears and nobody knows) or duplicate work (the queue re-delivers the task to a new worker, which starts over from scratch). Both are bad, and the second can be catastrophic when the lost work includes a side effect like "pay this vendor".

Reassigning a worker helps the task make progress. Checking ownership and upstream outcomes helps avoid incorrect writes and repeated effects.

Durability turns occasional disaster into a routine, bounded cost. We want:

  • Bounded rework: resume from recorded, completed steps and account for the in-flight operation.
  • Duplicate effects: a receiving service can enforce one logical operation within its supported idempotency scope and lifetime.
  • Accepted work: retain enough state to recover, complete, or report a terminal failure.
  • Deadline awareness: skip a new step if its estimated cost exceeds the remaining budget.

These are testable goals under the service’s stated failure model. When an external outcome cannot be established, record it as unresolved and keep the identifying information for reconciliation.

These problems occur in queue-backed workflows. Amazon SQS standard queues can deliver a message more than once. Temporal records workflow events and replays them to rebuild state, using recorded completed activity results during replay. Our fixture is a single-machine example and implements its own much smaller protocol. Amazon SQS delivery Temporal durable execution

Temporal replays deterministic Workflow code using completed Activity results already recorded in Event History. If a Worker performs an Activity effect and crashes before Temporal records completion, the Activity can execute again when its retry policy permits. The recurring operation needs its own idempotency or reconciliation plan. Temporal Activity Definition

Durability vs. Persistence

Persistence keeps data beyond a process lifetime. Durability here concerns committed state surviving the failure model. Keeping that state consistent with concurrent workers requires a separate concurrency protocol, and preventing duplicate external effects requires cooperation at their own boundary.

Imagine two workers both read the same snapshot, append a different event in memory, and overwrite the snapshot. The later write can drop the first addition. An atomic append or a checked state transition prevents that lost-update pattern.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy