Track 03 · Agents & toolsLesson 07 of 12

Workflows that survive restarts

Durable execution for processes that run for days through outages and deploys.

What you'll be able to do

What you'll be able to do

01
  1. Explain why an agent process that waits for days breaks on restarts, deploys and outages, and what durable execution does about it: event history, replay and durable timers.
  2. Separate a long-running agent process into deterministic workflow code and activities, and place every model call, tool call and clock read on the correct side.
  3. Implement a Temporal workflow with per-activity timeouts and retry policies, a signal for incoming documents, an update for human approval, a query for status, and a multi-day timeout.
  4. Diagnose a non-determinism failure from a replay and choose a safe versioning strategy for workflow code that has executions in flight.
  5. Design idempotency keys and compensation (sagas) so retries and partial failures never duplicate or orphan an external action.
  6. Choose between Temporal and its alternatives for a customer's estate, and defend the choice to a platform owner.
Before you start

Before you start

The short version

The short version

Prior-authorisation intake waits: days for a fax, hours for a nurse's approval. A process that holds that wait in memory (a sleeping thread, an asyncio task, a polling loop) loses its place when the pod restarts, the deploy rolls or the region fails. Durable execution persists every step. You write the process as workflow code that only orchestrates, and put every side effect (model calls, tool calls, emails) in activities. The engine records each activity's result in an event history. After a crash, a new worker replays the workflow code against the history: completed steps return their recorded results instead of running again. For replay to work, workflow code must be deterministic: no wall clock, no randomness, no I/O, no LLM calls. Fourteen-day timers, signals and updates that deliver documents and approvals, and status queries all become durable. Activities still run at least once, so writes still need idempotency keys.

Key takeaways:

  • Workflow code decides; activities do. Every model call is an activity.
  • Replay re-runs your workflow code from the start against recorded results; any difference in the commands it issues is a non-determinism error.
  • Waits are durable timers and signals, not sleeping processes. A case waiting 14 days costs nothing while it waits.
  • Changing workflow code with executions in flight is a versioning problem. Test it with replay before you deploy.
  • Durable execution gives you exactly-once orchestration, not exactly-once side effects. Idempotency keys and compensation remain your job.

Pro lesson

The rest of this lesson is in Pro.

The mental model, worked example, field note, failure table, exercise and self-check, with the voice tutor.

  • Every stage and specialisation, in full
  • Every lab and every role project
  • Halden weeks 2–10, on your record
  • Every drill, live in the playground
  • All solutions, plus the server judge
  • Lab Assistant and every Teach with AI