Phase 2: Control & Containment · ~60 minutes · Python (stdlib · checkpoint and rollback state machine)
Checkpoints and Rollback
Every graph-state transition persists.
Introduction
When a worker crashes, its lease expires and another worker picks up at the latest checkpoint. Cloudflare Durable Objects hold state across hours or weeks. Propose-then-commit (Human-in-the-Loop: Propose-Then-Commit) defines a rollback plan per action. Post-action verification closes the loop. EU AI Act Article 14 makes effective human oversight mandatory for high-risk systems — in practice this means checkpoints must be queryable, rollbacks must be rehearsed, and the audit trail must survive a deploy. The sharp failure mode: without idempotency keys and precondition checks, a retry after a transient failure can double-execute an already-approved action. Post-action verification is what catches it.
- Type: Learn
- Languages: Python (stdlib, checkpoint and rollback state machine)
- Prerequisites: Long-Running Background Agents: Durable Execution, Human-in-the-Loop: Propose-Then-Commit
- Time: ~60 minutes
The Problem
Durable execution (Long-Running Background Agents: Durable Execution) makes a crashed agent resumable. Propose-then-commit (Human-in-the-Loop: Propose-Then-Commit) makes an approved action auditable. This lesson joins them: what happens when an approved action executes partially, crashes, and resumes? When does the rollback run, and against what state?
Real systems wire this up differently:
- LangGraph checkpoints every graph-state transition to PostgreSQL. On worker crash, the lease releases and another worker resumes at the latest checkpoint. Workflows pause on
interrupt(), which itself persists. - Cloudflare Durable Objects hold per-key state across hours or weeks. Co-locate the computation with the storage for the approved action.
- Microsoft Agent Framework exposes
Checkpoint primitives in the workflow API; replay plus idempotency covers retries.
In every case, the combination that actually works is: idempotency key (prevents double-execute) + precondition check (state is still what we approved against) + post-action verify (the side effect actually happened) + rollback on verify-fail.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers The Concept, Build, Check Yourself, Key Terms & Next — plus a hands-on lab, quiz, and project artifact.
Create a free account — the opening phases of 29 of 35 courses, and the first lesson of every phase, are free, no credit card.
Browse all courses · View pricing · DeVenture Academy