| Name | Type | Description |
|---|---|---|
driver* | Driver | A Neo4j Driver instance. |
database | str | None | Default: NoneOptional database name (defaults to Neo4j default). |
| Name | Type |
|---|---|
| driver | Driver |
| database | str | None |
Synchronous Neo4j checkpoint saver for LangGraph.
This class implements the BaseCheckpointSaver interface using Neo4j as the persistence backend with a proper graph model. It supports storing checkpoints, channel states, and pending writes using relationships for efficient traversal.
Graph Model:
(:Thread)-[:HAS_CHECKPOINT]->(:Checkpoint)-[:PREVIOUS]->(:Checkpoint) (:Checkpoint)-[:HAS_CHANNEL]->(:ChannelState) (:Checkpoint)-[:HAS_WRITE]->(:PendingWrite)
Example:
Using from_conn_string (recommended)
with Neo4jSaver.from_conn_string( ... uri="bolt://localhost:7687", ... user="neo4j", ... password="password" ... ) as checkpointer: ... checkpointer.setup() # Create indexes (run once) ... graph = builder.compile(checkpointer=checkpointer) ... result = graph.invoke({"messages": [...]}, config)
Using existing driver
driver = GraphDatabase.driver(uri, auth=(user, password)) checkpointer = Neo4jSaver(driver) checkpointer.setup()