Checkpoints Module
The checkpoints module provides file-level checkpointing using a shadow git repository to track and restore file changes made by agents.Installation
Features
- Automatic checkpointing before file modifications
- Rewind to any previous checkpoint
- Diff between checkpoints
- Restore files and conversation state together
Quick Start
Classes
CheckpointService
Main service for managing checkpoints.Constructor
| Parameter | Type | Description |
|---|---|---|
workspace_dir | str | Directory to track |
storage_dir | str | Where to store checkpoints |
Methods
| Method | Description |
|---|---|
initialize() | Initialize the shadow git repository |
save(message) | Save a checkpoint with a message |
restore(checkpoint_id) | Restore to a specific checkpoint |
diff(from_id, to_id) | Get diff between two checkpoints |
list() | List all checkpoints |
get(checkpoint_id) | Get checkpoint details |
delete(checkpoint_id) | Delete a checkpoint |
Checkpoint
Represents a single checkpoint.Attributes
| Attribute | Type | Description |
|---|---|---|
id | str | Unique checkpoint ID |
message | str | Checkpoint message |
timestamp | datetime | When checkpoint was created |
files_changed | list[str] | List of changed files |
metadata | dict | Additional metadata |
CheckpointDiff
Diff between two checkpoints.Attributes
| Attribute | Type | Description |
|---|---|---|
from_id | str | Source checkpoint ID |
to_id | str | Target checkpoint ID |
added_files | list[str] | Files added |
modified_files | list[str] | Files modified |
deleted_files | list[str] | Files deleted |
diff_content | str | Full diff content |
CheckpointConfig
Configuration for checkpoint service.Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
auto_checkpoint | bool | True | Auto-checkpoint before changes |
max_checkpoints | int | 100 | Maximum checkpoints to keep |
exclude_patterns | list[str] | [] | Patterns to exclude |
CheckpointEvent
Events emitted by the checkpoint service.Usage Examples
Basic Checkpointing
With Agent
Automatic Checkpointing
Excluding Files
Best Practices
- Initialize early - Initialize checkpoint service before agent starts
- Meaningful messages - Use descriptive checkpoint messages
- Exclude large files - Exclude logs, dependencies, build artifacts
- Limit checkpoints - Set max_checkpoints to prevent disk bloat
- Regular cleanup - Delete old checkpoints periodically

