[PR #5258] Add checkpoint memgraph #4333

Closed
opened 2026-02-20 17:50:02 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5258

State: closed
Merged: No


feat: Add checkpoint-memgraph Package

Description

This pull request introduces the langgraph-checkpoint-memgraph package, providing a robust and feature-rich integration with Memgraph as a backend for both a key-value store and a checkpoint saver. This implementation allows LangGraph applications to persist and manage state within a Memgraph graph database.

The package includes two primary components:

  1. MemgraphStore: A synchronous, BaseStore-compliant client for general-purpose data storage in Memgraph.
  2. MemgraphSaver / AsyncMemgraphSaver: A BaseCheckpointSaver-compliant implementation for persisting LangGraph checkpoints.

Key Features

MemgraphStore

The MemgraphStore provides a comprehensive interface for interacting with Memgraph.

  • Unified Interface: Supports key-value storage, document search, and vector similarity search through a single class.
  • TTL (Time-To-Live) Support: Nodes can be set to expire automatically. A background sweeper thread (start_ttl_sweeper) can be enabled to periodically clean up expired data, ensuring efficient database management.
  • Vector Search: Integrates with embedding models to store and perform similarity searches on text data. Configuration is handled via the MemgraphIndexConfig.
  • Robust Connection Management: Can be instantiated directly with a memgraph.Driver instance or conveniently from a connection string using the from_conn_string class method.
  • Idempotent Setup: Includes a setup() method to create necessary database constraints and indexes, simplifying initial configuration.

MemgraphSaver & AsyncMemgraphSaver

The checkpoint saver provides a complete checkpointing solution built directly on Memgraph.

  • Full Checkpoint Lifecycle: Implements all methods required by the BaseCheckpointSaver interface, including get_tuple, put, list, and delete_thread.
  • Async and Sync Support: Provides both MemgraphSaver for synchronous operations and AsyncMemgraphSaver for asynchronous applications, ensuring seamless integration into any LangGraph workflow.
  • Transactional Integrity: Leverages Memgraph's transactional capabilities to ensure that checkpoint operations are atomic.

Implementation Details

  • The package provides two distinct, parallel implementations: MemgraphStore for generic key-value operations and MemgraphSaver for managing LangGraph checkpoints.
  • MemgraphStore persists data in (:StoreItem) nodes, offering a flat key-value structure with optional TTL and vector indexing.
  • MemgraphSaver implements a graph model where checkpoints are grouped by a shared thread_id property. It creates (:Checkpoint) nodes to store the state of each run, and the parent_checkpoint_id property on these nodes creates a sequential history. Associated data is stored in (:Blob) and (:Write) nodes, which are also linked by the thread_id.
  • Helper modules (_internal.py, _ainternal.py) provide shared connection and session management logic for both sync and async operations.
  • Checkpoints are serialized to JSON before being stored as a property on the :Checkpoint node, allowing for efficient storage and retrieval of complex state objects.
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5258 **State:** closed **Merged:** No --- ### feat: Add `checkpoint-memgraph` Package #### Description This pull request introduces the `langgraph-checkpoint-memgraph` package, providing a robust and feature-rich integration with Memgraph as a backend for both a key-value store and a checkpoint saver. This implementation allows LangGraph applications to persist and manage state within a Memgraph graph database. The package includes two primary components: 1. **`MemgraphStore`**: A synchronous, `BaseStore`-compliant client for general-purpose data storage in Memgraph. 2. **`MemgraphSaver` / `AsyncMemgraphSaver`**: A `BaseCheckpointSaver`-compliant implementation for persisting LangGraph checkpoints. ### Key Features #### `MemgraphStore` The `MemgraphStore` provides a comprehensive interface for interacting with Memgraph. - **Unified Interface**: Supports key-value storage, document search, and vector similarity search through a single class. - **TTL (Time-To-Live) Support**: Nodes can be set to expire automatically. A background sweeper thread (`start_ttl_sweeper`) can be enabled to periodically clean up expired data, ensuring efficient database management. - **Vector Search**: Integrates with embedding models to store and perform similarity searches on text data. Configuration is handled via the `MemgraphIndexConfig`. - **Robust Connection Management**: Can be instantiated directly with a `memgraph.Driver` instance or conveniently from a connection string using the `from_conn_string` class method. - **Idempotent Setup**: Includes a `setup()` method to create necessary database constraints and indexes, simplifying initial configuration. #### `MemgraphSaver` & `AsyncMemgraphSaver` The checkpoint saver provides a complete checkpointing solution built directly on Memgraph. - **Full Checkpoint Lifecycle**: Implements all methods required by the `BaseCheckpointSaver` interface, including `get_tuple`, `put`, `list`, and `delete_thread`. - **Async and Sync Support**: Provides both `MemgraphSaver` for synchronous operations and `AsyncMemgraphSaver` for asynchronous applications, ensuring seamless integration into any LangGraph workflow. - **Transactional Integrity**: Leverages Memgraph's transactional capabilities to ensure that checkpoint operations are atomic. ### Implementation Details - The package provides two distinct, parallel implementations: `MemgraphStore` for generic key-value operations and `MemgraphSaver` for managing LangGraph checkpoints. - **`MemgraphStore`** persists data in `(:StoreItem)` nodes, offering a flat key-value structure with optional TTL and vector indexing. - **`MemgraphSaver`** implements a graph model where checkpoints are grouped by a shared `thread_id` property. It creates `(:Checkpoint)` nodes to store the state of each run, and the `parent_checkpoint_id` property on these nodes creates a sequential history. Associated data is stored in `(:Blob)` and `(:Write)` nodes, which are also linked by the `thread_id`. - Helper modules (`_internal.py`, `_ainternal.py`) provide shared connection and session management logic for both sync and async operations. - Checkpoints are serialized to JSON before being stored as a property on the `:Checkpoint` node, allowing for efficient storage and retrieval of complex state objects.
yindo added the pull-request label 2026-02-20 17:50:02 -05:00
yindo closed this issue 2026-02-20 17:50:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4333