When to reach for it
- Agent runs are lengthy or expensive.
- External systems might temporarily fail.
- Manual review between steps is required.
Save state. Resume cleanly.
The execution state is persisted at well-defined boundaries (per node or super-step) so an interrupted or failed run resumes from the last checkpoint instead of restarting — the durable-execution substrate that also enables human-in-the-loop pauses.
In practiceA multi-hour data-migration agent checkpoints after each table, so a network blip resumes from the last table instead of restarting.
After every finished step the state of the run is written to a store. A run that stops, for whatever reason, starts again from the last entry and not from the beginning.
1 · While the run is healthy
2 · After an interruption
| Table | First run | After the restart |
|---|---|---|
| customers | Migrated, checkpoint 1 | Skipped |
| orders | Migrated, checkpoint 2 | Skipped |
| invoices | The network fails halfway. No checkpoint | Runs again from its start |
| payments | Not reached | Migrated, checkpoint 4 |
| audit_log | Not reached | Migrated, checkpoint 5 |
def run(steps, thread_id, state=None):
saved = store.latest(thread_id) # a checkpoint exists: resume
start = saved.step + 1 if saved else 0
state = saved.state if saved else state
for index in range(start, len(steps)):
state = steps[index](state) # may fail: network, timeout, crash
# a checkpoint after every finished step
store.save(thread_id, step=index, state=state)
return stateWhen to reach for it
When it backfires
The checkpoint serializes the full state including API keys and user PII. A resumed run leaks sensitive data to logs.
Countermeasure
Redact secrets before serialization. Store sensitive fields in a vault and reference them by handle in the checkpoint.
The agent resumes from a checkpoint but the external world has changed. The tool state in the checkpoint is now invalid.
Countermeasure
Invalidate tool-related state on resume. Re-run discovery or validation before continuing tool-dependent branches.
EU law
Duties from EU law that this pattern helps meet, or that land on it. A reading aid, not legal advice.
An engineer's reading aid, not legal advice. The legal texts and their interpretation are authoritative.
Next pattern
Search patterns, frameworks, and pages.