1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson →
The LangGraph store
The LangGraph store is a key-value store for JSON documents, organised by namespace, that LangMem's stateful parts read and write so memories outlive the Python process that made them.
Last updated: 30 Sep, 2026 · LangMem 0.0.30
So far every memory lived in a Python list and vanished when the script ended. LangMem's store managers and memory tools save to a LangGraph BaseStore instead. This lesson uses the store directly, with no model, so you know what the later lessons are writing to.
Syntax:
store.put(namespace, key, value) # namespace is a tuple, value a dict
store.get(namespace, key) # an Item, or None
store.search(namespace_prefix) # the Items under that namespace
store.delete(namespace, key)A namespace per customer
A namespace is a tuple of strings, like a folder path. ("memories", "asha") holds only Asha's memories.
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
store.put(("memories", "asha"), "contact", {"content": "Wants us to email her"})
store.put(("memories", "ravi"), "contact", {"content": "Prefers a phone call"})Reading one item back
item = store.get(("memories", "asha"), "contact")
print(item.value)Putting, reading and deleting
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
store.put(("memories", "asha"), "contact", {"content": "Wants us to email her"})
store.put(("memories", "ravi"), "contact", {"content": "Prefers a phone call"})
print(store.get(("memories", "asha"), "contact").value)
print([item.key for item in store.search(("memories", "asha"))])
print(store.list_namespaces())
store.put(("memories", "asha"), "contact", {"content": "Wants us to text her"})
print(store.get(("memories", "asha"), "contact").value)
store.delete(("memories", "asha"), "contact")
print(store.get(("memories", "asha"), "contact"))Output
{'content': 'Wants us to email her'}
['contact']
[('memories', 'asha'), ('memories', 'ravi')]
{'content': 'Wants us to text her'}
NoneWhat each call returned
- get returned an
Item; itsvalueis the dictionary that was put. - search on Asha's namespace found only her key,
contact. Ravi's item is in another namespace. - list_namespaces shows both customers' namespaces.
- A second put to the same namespace and key replaced the value; there is no history.
- delete removed it, so the last
getprintedNone.
Store vs checkpointer
| Store | Checkpointer | |
|---|---|---|
| Holds | Documents you put, by namespace and key | The state of one conversation thread |
| Shared across threads | Yes | No, one history per thread_id |
| LangMem uses it for | Long-term memories | Nothing; your agent uses it for the chat history |
| In-memory class | InMemoryStore | InMemorySaver |
Where the store is used
- As the place a store manager writes memories after a chat.
- As the backend of an agent's memory tools.
- For any per-user data your agent should read later: settings, notes, profiles.
Watch out.
InMemoryStore lives in the Python process. Restart the script and every memory is gone; Integrations swaps in a store that writes to disk or a database.Related
- Previous: Episodic memory
- Next: Semantic search
- Reference: LangGraph memory store
Try it yourself
- Search the prefix
("memories",)and see which items it finds. - Store a nested dictionary and read one field back.
- Print an item's
created_atandupdated_atafter a second put.
This is what real progress feels like.