Skip to main content

Checkpoint and Fork

QitOS checkpoints let you save an agent’s state at any step, resume a run after interruption, and fork a run to explore alternative paths — all without rerunning from scratch. This is essential for:
  • Long-running tasks that may be interrupted (network errors, budget limits)
  • Branching experiments where you want to explore “what if?” from a particular step
  • Time-travel debugging where you restore state from an earlier checkpoint

Step 1: Basic Checkpointing

Create a CheckpointStore and configure the Engine to use it:
For persistent storage across sessions, use SqliteCheckpointStore:

Step 2: Resuming a Run

If a run is interrupted, resume from the last checkpoint:
The Engine restores the state from the latest checkpoint and continues execution from where it left off.

Step 3: Forking a Checkpoint

Forking creates a new branch from an existing checkpoint, allowing you to explore alternative paths without affecting the original run:
The original run is untouched. The forked run starts from the same state but can follow a different path.

Step 4: Time-Travel (Same-Thread Fork)

If you omit new_thread_id, the fork replaces the current state within the same thread — useful for “undo and retry” scenarios:

Step 5: Durability Modes

Control how aggressively checkpoints are persisted:

Step 6: State Version Tracking

Track which state fields changed between checkpoints:

Critic System

Hook Lifecycle