Skip to main content
A checkpointer turns a graph from a one-shot computation into something you can pause, inspect, edit, and resume. It’s also the foundation for human-in-the-loop (which needs resume) and for production durability (you survive process restarts).

What a checkpointer is

Three implementations ship in the box; bring your own for anything else.

Quick example

Source: examples/v2/05_checkpoint_resume.rs.

Inspecting state

Compiled graphs expose the inspection surface directly:
Use this for debug UIs, audit trails, and step-through replay.

Editing state

Sometimes the human in the loop should fix the state before resuming — correct a typo, drop a tool result, change a counter. update_state writes a new snapshot at a given step:
Subsequent resume(run_id, step, state, cfg) reads from this updated state, so the rewind is real.

Resume after an interrupt

When a graph pauses (because of with_interrupt_before / with_interrupt_after), invoke returns Err(CognisError::GraphInterrupted { kind, step, .. }). That’s not a failure — it’s a pause. The shape:
The kind tells you whether you stopped before or after the named node. The step is what you pass back to resume.

Choosing a backend

A single graph holds one checkpointer — but you can attach different checkpointers to different runs by compiling per-request if you need per-tenant separation.

Subgraph isolation

Subgraphs use checkpoint_ns to isolate their state from the parent. Nested graphs end up with namespaced run trees:
get_state_history on a subgraph only sees the sub-tree, so debugging is local.

How it works

  • A checkpoint is taken after each superstep. That’s also when observers fire OnCheckpoint.
  • Checkpointers serialize state. S: Serialize is required for Sqlite / Postgres backends. The in-memory one clones.
  • Resume is exact. resume(run_id, step, state, cfg) continues from the same superstep with the seeded state, preserving observer and metadata propagation.
  • update_state and resume are independent. You can call update_state zero, one, or many times before resume.

See also

Human-in-the-loop

Pause, approve, edit, resume.

Patterns → HITL approval

A complete approval flow with checkpoints.

Production → Going to production

Picking a checkpointer for your stack.