A checkpointer saves a snapshot of graph state at each step, organised into threads. Compiling a graph with a checkpointer enables memory between interactions: a follow-up message sent to the same thread continues from the saved state instead of starting over.
Before you start
You need a working LangGraph StateGraph. Note that MemorySaver stores checkpoints in memory, which is fine for local development and testing, and gone the moment the process restarts.
Compile the graph with the checkpointer
Create a MemorySaver checkpointer and pass it when you compile the graph. When you invoke the graph, pass a config with a thread_id inside the configurable section: the checkpointer uses the thread_id as the primary key for storing and retrieving checkpoints. Without it, the checkpointer cannot save state or resume execution.
Test with a follow-up in the same thread
Invoke the graph with a first message and a thread_id, then invoke it again with a follow-up message and the same thread_id. Check the second reply refers to the first message. Then invoke it with a new thread_id and check it starts fresh.
Worked example: Two threads for a fictional bookshop agent
Maple Books is a fictional bookshop. Its LangGraph agent uses a MemorySaver checkpointer. The table shows two threads.
| Thread | Messages | Agent remembers? |
|---|---|---|
| thread-ana | Wants a bicycle repair book under 30 dollars | Yes, within this thread |
| thread-ben | Asks about cookbooks | Yes, but only the cookbook topic |
Expected result (UNTESTED): the follow-up in thread-ana is answered without repeating the topic or the budget, while thread-ben starts fresh. We checked the LangGraph checkpointers documentation, which describes threads, MemorySaver and the thread_id requirement, but we did not run the graph on this machine.
Limits
MemorySaver is in-memory only, so a restart loses every thread. For anything that must survive a restart, use a persistent checkpointer such as SQLite or Postgres. One thread per user or conversation is the standard pattern.
