Skip to main content

Checkpointing

A checkpointer saves the graph's state after every step, keyed by a thread_id. Compile with one and any run becomes resumable — after a crash, a restart, or a deliberate pause for human review.

from langgraph.checkpoint.memory import InMemorySaver

graph = builder.compile(checkpointer=InMemorySaver())

config = {"configurable": {"thread_id": "customer_123"}}
graph.invoke({"messages": [("user", "hi")]}, config)

# later, same thread_id: resumes with full prior state
graph.invoke({"messages": [("user", "and then?")]}, config)
CheckpointerStorageUse it when
InMemorySaverprocess memorylocal development, tests
SqliteSaverlocal SQLite filesingle-process durability, prototypes
PostgresSaverPostgresproduction, multi-process, multi-instance

A new thread_id starts a fresh, empty state; reusing one resumes exactly where that thread left off. Inspect prior states with graph.get_state_history(config).

tip

InMemorySaver is fine for a demo but disappears with the process. Anything a user expects to persist across a restart needs SqliteSaver or PostgresSaver.

See also