Store: memory across conversations
A Store holds long-term memory shared across threads: facts kept as key-value data under a namespace, with put, get and search.
Last updated: 27 Sep, 2026 · LangGraph 1.2
A checkpointer remembers one conversation. A Store remembers a user across all of them, such as a name or a preference that should still be known in a brand-new thread next week.
The Store API: put, get and search
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
namespace = (user_id, "facts") # a tuple
store.put(namespace, key, {"data": ...}) # write
store.get(namespace, key) # read one
store.search(namespace, query="...") # find matching
graph = builder.compile(store=store) # give it to the graphA Store keeps facts as key-value data under a namespace. Write a couple of facts, then read them back. Build it one piece at a time.
Creating a store
Import the in-memory store and create one.
from langgraph.store.memory import InMemoryStore
store = InMemoryStore() # long-term memory shared across threadsThe namespace
A namespace is a tuple, here the user id and a label. It keeps one user's facts apart from another's.
ns = ("user_1", "facts") # namespace: this user's factsWriting facts
Write two facts with put. Each call takes the namespace, a key, and a small dictionary of data.
store.put(ns, "1", {"data": "likes pizza"}) # key "1"
store.put(ns, "2", {"data": "lives in Pune"}) # key "2"Reading facts back
Read them back with search, which returns every fact in the namespace. Pull the data out of each item.
hits = store.search(ns) # every fact in the namespace
print([item.value["data"] for item in hits]) # pull the data out of eachThe store in a run
The same pieces in one file.
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
ns = ("user_1", "facts")
store.put(ns, "1", {"data": "likes pizza"})
store.put(ns, "2", {"data": "lives in Pune"})
hits = store.search(ns)
print([item.value["data"] for item in hits])What search returned
- The namespace is a tuple, here the user's id plus a label, which keeps one user's facts apart from another's.
putwrites a fact,getreads one by key, andsearchreturns the facts in a namespace.- With embeddings configured,
search(ns, query="food")finds facts by meaning, not exact match.
Checkpointer vs Store
| Checkpointer | Store | |
|---|---|---|
| Scope | One conversation thread | Across all threads |
| Holds | The full state per step | Key-value facts |
| Use for | Short-term conversation memory | Long-term user facts and preferences |
When you need a store
- Remembering a user's name, preferences, or past decisions between sessions.
- Any fact that should outlive a single conversation.
InMemoryStore is for learning and tests; use PostgresStore or RedisStore in production. Namespaces are tuples, not strings.Related
- Previous: Checkpointer: memory across turns
- Next: Runtime context: per-run data with context_schema
- Reference: Memory
- Add a third fact and search again.
- Use
store.get(ns, "1")and print its value.
Slow is fine. Stopping is the only problem.