Guide

Long-term memory for a LangGraph agent

LangGraph gives your agent a store for memory that survives across threads. The built-in ones are key-value stores: put overwrites, delete erases. Correct for a cache, wrong for memory, because the question you will actually ask later is “what did the agent believe last week, and what changed it”. This guide wires the same interface to a backend that keeps the history.

Setup

Two installs and one command:

pip install "omem-infrastructure[langgraph]"
omem-server

omem-server prints a project id and API key on first run and serves a dashboard on the same port. SQLite underneath, no other dependencies, runs offline.

The store

from omem import Memory
from omem.integrations.langgraph_store import OmemStore
 
store = OmemStore(Memory(
api_key="omem_sk_...", # printed on first run
project="proj_...",
base_url="http://127.0.0.1:8787",
))
 
store.put(("memories", "alice"), "billing", {"text": "prefers annual billing"})
store.get(("memories", "alice"), "billing").value
# -> {"text": "prefers annual billing"}

Hand it to create_react_agent(..., store=store) or any LangGraph graph, exactly as you would hand it an InMemoryStore. Cross-thread memory works as before.

What the second write does

store.put(("memories", "alice"), "billing", {"text": "switched to monthly"})

In a key-value store the annual preference now no longer exists, anywhere. Here it is superseded: the old value stays on the record with the moment it stopped being believed, and the dashboard shows both, with the interval each was held and which write ended it. delete works the same way: the key stops resolving, the history of what it held survives. Every write is attributed, so mem.why(assertion_id) answers where a memory came from.

Honest limitations

Vector search over the store interface is not implemented yet; search(query=...) raises rather than quietly returning unranked results. Every operation is a network round trip to a real server, where InMemoryStore is a dict. Use this where the audit trail is worth more than the microseconds.

Where to go next

The engine underneath does more than the store interface exposes: contradiction tracking, declared inference rules whose conclusions are withdrawn when premises die, and a benchmark for whether memory systems assert things nobody told them. Start with the quickstart, or read the Python guide for the full belief-tracking surface.