Lesson 6 of 11
Chapter 18 . LangGraph . Lesson 6 of 11

Checkpoints and memory

A checkpointer saves the state after every step. Each thread_id keeps its own history.

01Real-world example

Illustration: The nightly regression and the smoke run keep separate histories, like two CI pipelines that never overwrite each other.
The nightly regression and the smoke run keep separate histories, like two CI pipelines that never overwrite each other.

02The graph

Checkpoints and memory as a graph
One graph, two thread_ids, two separate memories.

03How the code does it

  • compile(checkpointer=InMemorySaver()) saves the state for the input and after every step.
  • thread_id picks which saved state to continue: nightly-regression and smoke never see each other's runs.
  • get_state() returns the latest snapshot; get_state_history() returns every checkpoint.
  • InMemorySaver forgets when the process exits. A SQLite or Postgres saver keeps the history across restarts.

Key points

  • compile(checkpointer=InMemorySaver())
  • Pass a thread_id in the config
  • Use a SQLite or Postgres saver to survive restarts

04Run it

terminal
cd chapter_18_LangGraph/src/chapters
python 006_Checkpointer_Memory.py
output
nightly-regression remembers: ['run #1', 'run #2', 'run #3']
smoke is separate:            ['run #1']