Checkpointers
Saving state.
So far, every run starts from scratch. A checkpointer changes that. After every step, it saves the state. The next run on the same conversation continues from the saved state.

- Runs start from scratch
- Save after every step
- Continue next time
A graph that remembers
Visits uses operator add, and the node adds one each time. We compile with an in memory saver. The config holds a thread ID, which names the conversation. We invoke twice on the same thread. Run it. The second run continues from the first, so visits reaches two.
import operator
from typing import Annotated, TypedDict
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import StateGraph, START
class State(TypedDict):
visits: Annotated[int, operator.add]
def visit(s):
return {"visits": 1}
b = StateGraph(State); b.add_node(visit); b.add_edge(START, "visit")
graph = b.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "sam"}}
for run in [1, 2]:
print(f"run {run}: visits =", graph.invoke({}, config)["visits"])run 1: visits = 1 run 2: visits = 2
What checkpointers give you
Checkpointers unlock most of LangGraph's power. Memory across turns. Pausing for a human, and resuming later. Looking back at every past step. And recovering after a crash, from the last saved step.
| key | value |
|---|---|
| Memory | across turns |
| Pause | resume later |
| History | every step saved |
| Recovery | after a crash |
Summary
A checkpointer saves the state after every step, and a thread ID names the conversation. Next, keeping conversations apart with threads.
Key takeaways- compile(checkpointer=...)
- thread_id in config
- Saved every step