LangGraphLangGraph 1.2 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
38 small wins to finish your pathNext lesson →

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.

python
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 graph

A 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.

python
from langgraph.store.memory import InMemoryStore

store = InMemoryStore()   # long-term memory shared across threads

The namespace

A namespace is a tuple, here the user id and a label. It keeps one user's facts apart from another's.

python
ns = ("user_1", "facts")   # namespace: this user's facts

Writing facts

Write two facts with put. Each call takes the namespace, a key, and a small dictionary of data.

python
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.

python
hits = store.search(ns)                       # every fact in the namespace
print([item.value["data"] for item in hits])  # pull the data out of each

The store in a run

The same pieces in one file.

Example
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.
  • put writes a fact, get reads one by key, and search returns the facts in a namespace.
  • With embeddings configured, search(ns, query="food") finds facts by meaning, not exact match.

Checkpointer vs Store

CheckpointerStore
ScopeOne conversation threadAcross all threads
HoldsThe full state per stepKey-value facts
Use forShort-term conversation memoryLong-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.
Watch out. InMemoryStore is for learning and tests; use PostgresStore or RedisStore in production. Namespaces are tuples, not strings.
Try it yourself
  • Add a third fact and search again.
  • Use store.get(ns, "1") and print its value.

Slow is fine. Stopping is the only problem.