Skip to content

AI 302 · Module 3

Checkpointing, Resume & Durable Execution

If a run stops halfway, how does the system continue safely instead of starting over?

Start Section 1
0 / 6 completed
Sync my progressJoin a session to keep progress across devices and share it with your instructor

Info

After you join, your completed lesson numbers are sent to your instructor together with your learner code, so they can see your progress. Use the codes your instructor gave you, and do not enter your name, company secrets or other personal data. Progress is kept with the rest of that session's data.

Learning objectives

  • Explain what a checkpoint is and what a snapshot of run state should contain
  • Decide where a checkpoint is safe and where it is not, using five questions
  • Distinguish resume from restart, and describe a recovery point and execution identity
  • Explain side effects, the idempotency concept and the risk of duplicate execution on replay
  • Describe durable execution as continuing from a known valid state after interruption
  • Produce a Checkpoint & Resume Plan for a workflow

Problem and need

8 min

The run stopped halfway. Do we start over?

In Module 2 you described a run as state moving through steps and transitions. Real runs get interrupted: a service restarts, a time limit is reached, a person closes a session. The core question of this module is: if a run stops halfway, how does the system continue safely instead of starting over?

Work scenario (simulated)

A department workflow has five steps: collect the requests, classify them, draft replies, send the replies, and record the outcome. The run stops after the replies were sent but before the outcome was recorded. Nothing was saved, so the team restarts the whole run. Every reply is sent a second time, and the recipients receive duplicate messages.

  • Restarting from the beginning wastes finished work
  • Restarting can also repeat actions that already happened in the outside world
  • Continuing safely needs saved state and a clear idea of what is already done
  • Where and how to save is a design decision made in the harness

Warning

Continuing a run does not remove the need for review. A person stays accountable for what the workflow does, including anything it repeats after an interruption.

Key takeaway: An interruption is normal. The design question is how the run continues from a known point without losing work or repeating actions.

Checkpoint concepts

9 min

The checkpoint model: snapshot, persistence, recovery point

A checkpoint is a saved record of the run at a chosen point, so the run can continue from there later. The saved record is a snapshot of the run state. Saving it somewhere that survives the interruption is called persistence. The point you can return to is the recovery point.

The checkpoint model
  1. Step A: the run does some work
  2. Checkpoint 1: save a snapshot of the state
  3. Step B: the run does more work
  4. External Action: something changes in the outside world
  5. Checkpoint 2: save a snapshot that records the action as done
  6. Step C: the run continues

Text equivalent: the run alternates between doing work and saving a snapshot. After an interruption the run can return to the most recent checkpoint instead of the beginning. Checkpoint 2 comes after the external action, so it records that the action already happened.

What a snapshot may hold (simulated)
ItemWhy keep itExample
Execution identitySo the system knows which run this isRun ID for the weekly request batch
Current stepSo it knows where to continueDraft replies, item 12 of 40
Step outputsSo finished work is not redoneThe 40 classified requests
Action recordsSo it knows what already happened outsideReplies 1 to 11 sent, with confirmation
Pending itemsSo nothing is forgottenItems 12 to 40 not yet drafted
Check yourself

Why does the snapshot store an execution identity and a record of completed actions, not only the current step?

Why does the snapshot store an execution identity and a record of completed actions, not only the current step?

Key takeaway: A checkpoint saves a snapshot of run state, persisted so that the run has a recovery point to return to.

9 min

Where to checkpoint: not every point is safe

You could save state after every tiny action, but that is costly, and more importantly not every point is a safe checkpoint. A safe checkpoint is a point where returning to it gives a run that is correct and consistent. Five questions help you decide.

Five questions for a checkpoint location (simulated)
QuestionWhat it checksExample
Has an external action already happened?Whether the outside world has changedA reply was sent before this point
Is this step reversible?Whether the effect could be undoneA draft can be discarded, a sent notice cannot
Would replay duplicate an action?Whether running again repeats the effectReplaying "send reply" sends it twice
What state must be persisted?What the run needs to continue correctlyItem list, outputs, action records
What evidence confirms completion?How we know the step really finishedA delivery confirmation, not only "no error"

Safe checkpoint

  • Placed after a step is confirmed complete
  • Records the result of any external action
  • Returning here does not repeat an unconfirmed action

Unsafe checkpoint

  • Placed in the middle of an action whose outcome is unknown
  • Does not record what already happened outside
  • Returning here may repeat the action or skip it
Check yourself

A step sends a notice and then a checkpoint is saved before the send is confirmed. Why is this an unsafe checkpoint?

A step sends a notice and then a checkpoint is saved before the send is confirmed. Why is this an unsafe checkpoint?

Key takeaway: Place a checkpoint where the state is consistent and the result of any external action is confirmed and recorded.

Resume and duplicate risk

9 min

Resume, restart and the risk of duplicate execution

After an interruption the system can restart or resume. Restart begins again from the first step. Resume continues from a recovery point using the saved state. Resume saves work, but replaying steps can still repeat their side effects.

Restart

  • Begins again from the first step
  • Simple, and needs no saved state
  • Repeats finished work and may repeat side effects

Resume

  • Continues from the latest recovery point
  • Needs a persisted snapshot and an execution identity
  • Saves work, but must handle steps that ran partly
Ideas that make replay safer (simulated)
IdeaWhat it meansExample
Side effectA change made outside the runSending a message, updating a record
ReplayRunning a step again after an interruptionRe-running "send reply" on resume
IdempotencyDoing the action twice has the same effect as doing it onceMarking a request "answered" a second time changes nothing
Duplicate execution riskThe chance that replay repeats an action that is not idempotentA second copy of the same reply is sent
Action recordA saved note that the action already happenedReply 7 sent, with confirmation

This module teaches idempotency as a concept for reasoning about replay. If an action is not idempotent, the design should record that it happened, check the record before acting again, or place a human gate in front of it (Module 4).

Check yourself

A resumed run replays a step that sends a reply, and the send is not idempotent. What is the main risk?

A resumed run replays a step that sends a reply, and the send is not idempotent. What is the main risk?

Key takeaway: Resume saves work, but replay can repeat side effects. Reason about idempotency and record completed actions.

Durable execution

9 min

Durable execution, with an example framework mapping

Durable execution is the ability to survive an interruption and continue from a known valid state. It is a property of the design, not of one product. A durable design has saved state, a clear execution identity, safe checkpoints, and a defined resume behavior.

Durable execution concept
  1. Run in progress: state is saved at safe checkpoints
  2. Interruption: the run stops unexpectedly
  3. Locate: find the run by its execution identity
  4. Restore: load the latest valid snapshot
  5. Check: look at action records to avoid repeating actions
  6. Continue: resume from the recovery point

Text equivalent: while running, the system saves snapshots at safe checkpoints. After an interruption it finds the run by its identity, restores the latest valid snapshot, checks which actions were already recorded, and then continues instead of restarting.

Example only: how one stateful framework may map these concepts (LangGraph)
ConceptExample LangGraph mappingNote
StateGraph stateThe data carried through the run
StepNodeOne unit of work
TransitionEdge or conditional edgeHow the run moves to the next step
CheckpointCheckpointerSaves state so a run can be resumed
Human-in-the-LoopInterrupt and resume patternPauses for a person, then continues
RecoveryState-aware resume or alternate transitionContinues from saved state or takes another path

Info

This table is an example, not the definition. The concepts above work in any design or framework. You do not need to master any framework API to complete this course.
Check yourself

How should the framework mapping table be used in this module?

How should the framework mapping table be used in this module?

Key takeaway: Durable execution means continuing from a known valid state after interruption. Frameworks can implement it, and the concepts stay framework independent.

Practice and apply

11 min

Practice: Where Should We Checkpoint?

Activity 3 is called Where Should We Checkpoint? First work the example, then do it for your own workflow. Please do not enter real company secrets, client personal data or any unauthorized sensitive information in this exercise.

Worked example (simulated). Five-step request workflow
StepCheckpoint decisionReason
1. Collect the requestsCheckpoint afterReversible and cheap to save; the list is needed later
2. Classify the requestsCheckpoint afterSaves the classified results so they are not redone
3. Draft the repliesCheckpoint afterDrafts can be discarded, but saving avoids rework
4. Send the repliesUnsafe replay point; record each send with confirmationReplay would send duplicates
5. Record the outcomeCheckpoint after, then finishMarks the run complete
  1. List the steps
    Write the steps of your workflow in order.
  2. Place checkpoints
    Mark where to checkpoint, and use the five questions to justify each place.
  3. Mark unsafe replay points
    Circle steps whose side effects would repeat on replay, and note how to prevent that, for example an action record or a human gate.
  4. Define state and resume
    List what state must be stored, and write what the run does when it resumes: which snapshot it loads and what it checks first.

Info

Deliverable: the Checkpoint & Resume Plan, showing checkpoint locations, unsafe replay points, the state to store, and the resume behavior. It becomes part of your Agent Harness & Reliability Canvas.
Check yourself

In the worked example, why is step 4 (send the replies) marked as an unsafe replay point?

In the worked example, why is step 4 (send the replies) marked as an unsafe replay point?

Key takeaway: Human-AI-Human: a person decides which actions are safe to replay, the harness saves and resumes from known state, and a person reviews the outcome and stays responsible.

What next?