Skip to main content

LangGraph BaseStore backed by mnestic — embedded agent memory with atomic batches and one-call BM25+vector hybrid search.

Project description

langgraph-store-mnestic

A LangGraph BaseStore backed by mnestic — an embedded graph + vector + full-text database (a maintained fork of CozoDB). One process, one file, no server: agent long-term memory with atomic batches and in-engine hybrid retrieval (BM25 + vector fused with Reciprocal Rank Fusion — a fusion that Postgres + pgvector, LangGraph's default production store, cannot do in one system).

mnestic is a maintained fork of CozoDB; it is not the official CozoDB. Original design credit belongs to Ziyang Hu and the Cozo Project Authors.

pip install langgraph-store-mnestic
from langgraph_store_mnestic import MnesticStore

store = MnesticStore(
    engine="sqlite", path="memory.db",          # or engine="mem" for ephemeral
    index={"dims": 1536, "embed": my_embed_fn}, # any LangGraph IndexConfig embed
    ttl={"default_ttl": 60 * 24, "refresh_on_read": True},  # optional
)

store.put(("users", "u1"), "pref", {"text": "prefers window seats"})
hits = store.search(("users", "u1"), query="seating preference")

Use it in a graph like any store:

graph = builder.compile(store=store)

What you get

  • Atomic batch() — every write in a batch lands in one engine transaction. Under LangGraph's parallel fan-out this is the difference between correct recall and silently losing reads (a non-atomic prototype lost 36% of concurrent semantic reads; this store's concurrency suite gates on zero).
  • Hybrid search(query=...) — BM25 keyword + HNSW vector legs, namespace filter pushed into both index searches, RRF-fused and hydrated in a single engine snapshot. Without an index config the store is BM25-only (keyword search still works, no embeddings needed).
  • Collision-safe namespaces — any label content stays distinct (('a.b',) can never collide with ('a', 'b')).
  • TTL — per-item or default_ttl (minutes), lazy expiry on every read path, optional refresh-on-read, and a start_ttl_sweeper() background reclaimer.
  • Sync + async — full BaseStore surface; a* methods run the sync engine calls on the default executor.

LangGraph Platform (langgraph.json)

Custom stores are loadable by import path (alpha upstream feature):

# src/agent/store.py
from contextlib import asynccontextmanager
from langgraph_store_mnestic import MnesticStore

@asynccontextmanager
async def generate_store():
    store = MnesticStore(engine="sqlite", path="memory.db", index={...})
    try:
        yield store
    finally:
        store.close()
{ "store": { "path": "./src/agent/store.py:generate_store" } }

Notes

  • Requires Python ≥ 3.10 and langgraph-checkpoint >= 4.1.
  • The wheel build of mnestic ships mem, sqlite, and rocksdb engines (the sdist has no rocksdb).
  • The text index applies English stemming + stopwords: queries made only of very common words match nothing on the keyword leg (the vector leg still answers when an index config is present).
  • Filter operators supported in search(filter=...): $eq, $ne, $gt, $gte, $lt, $lte, with InMemoryStore-parity semantics.

License

Mozilla Public License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langgraph_store_mnestic-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_store_mnestic-0.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_store_mnestic-0.1.0.tar.gz.

File metadata

  • Download URL: langgraph_store_mnestic-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langgraph_store_mnestic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66b0d970f9844939deea615ea50c26bded24ecf36d35934e3bb1d445579c6459
MD5 b32e62b7fbcd7368f1f6e5cae1f18b9b
BLAKE2b-256 8cdee98a4bd40c4eb2c1ac98233b9369da851a8a8082ff7f63d39cba6fe3e3bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_store_mnestic-0.1.0.tar.gz:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langgraph_store_mnestic-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_store_mnestic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9958be245e41a48921a65f0b7bbd4f4b2aa696a727721fe9e63bc37002f8dcda
MD5 70cf8bc4d96f4ebd569dd842a8db15e3
BLAKE2b-256 079f7d32f0a1e5157e33aa0204d39bf0820f92b0843a8946f4ca51360aa51bf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_store_mnestic-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page