Skip to main content

Overview

Checkpoints enable you to save and restore workflow state, allowing:
  • Pause and resume: Stop a workflow and continue later
  • Fault tolerance: Recover from failures without losing progress
  • Long-running workflows: Handle workflows that take hours or days
  • State inspection: Debug by examining saved state at any point

How Checkpoints Work

Workflows execute in super steps. A checkpoint is automatically created at the end of each super step, capturing:
  • Messages: All messages exchanged between executors
  • State: Workflow state including user data and executor states
  • Pending requests: Any pending request-info events (for human-in-the-loop)
  • Iteration count: Current iteration number
  • Metadata: Workflow topology and version information
Checkpoint creation at super step boundaries

Enabling Checkpointing

Provide a CheckpointStorage when building your workflow:

Checkpoint Storage Backends

In-Memory Storage (Testing)

For development and testing:
Python
In-memory storage is lost when the process ends. Use file or database storage for production.

File Storage (Production)

Persist checkpoints to disk:
Python
Security: File storage uses pickle for serialization. Only load checkpoints from trusted sources.

Custom Storage

Implement CheckpointStorage protocol for custom backends:
Python

Capturing Checkpoints

Checkpoints are created automatically. Listen for checkpoint events:

Restoring from Checkpoints

Resume workflow execution from a saved checkpoint:

Executor State Persistence

Executors can save and restore internal state across checkpoints:
Python
Override on_checkpoint_save and on_checkpoint_restore to persist executor instance state across workflow restarts.

Managing Checkpoints

List Checkpoints

Python

Delete Old Checkpoints

Python

Checkpoint Metadata

Python

Automatic Recovery Pattern

Implement automatic retry with checkpoints:
Python

Checkpoint Compatibility

Checkpoints are tied to workflow topology:
  • Graph signature hash: Validates workflow structure hasn’t changed
  • Version: Checkpoint format version
  • Workflow name: Logical grouping of checkpoints
Changing workflow structure (adding/removing executors or edges) invalidates existing checkpoints. Maintain workflow name and topology for checkpoint compatibility.

Complete Example

Iterative computation with automatic checkpointing:
Python

Best Practices

  • Use InMemoryCheckpointStorage for tests and local development
  • Use FileCheckpointStorage for production single-node deployments
  • Use custom storage (database, blob storage) for distributed systems
  • Keep state serializable (primitive types, dataclasses)
  • Minimize state size - only persist essential data
  • Use executor state hooks (on_checkpoint_save/restore) for executor-specific state
  • Avoid storing large objects in workflow state
  • Implement retention policies (delete old checkpoints)
  • Monitor checkpoint storage size
  • Test checkpoint restoration regularly
  • Document checkpoint compatibility requirements
  • Handle checkpoint load failures gracefully
  • Validate checkpoint compatibility before restore
  • Log checkpoint operations for debugging
  • Provide fallback to fresh start if restore fails

Next Steps

Human-in-the-Loop

Combine checkpoints with human input for interactive workflows

Orchestration Patterns

Learn about sequential, concurrent, and conditional execution