1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
18 small wins to finish your pathNext lesson →
The LangGraph store: where memories live
LangGraph's store saves JSON documents under a namespace, a tuple like ("memories", "asha"), and a key. LangMem's stateful parts read and write it.
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
store.put(("memories", "asha"), "contact", {"content": "Wants us to email them"})
store.put(("memories", "ravi"), "contact", {"content": "Prefers to be called"})
print(store.get(("memories", "asha"), "contact").value)
print([item.key for item in store.search(("memories", "asha"))])
print(store.list_namespaces())put writes a dictionary under a namespace and key, get reads one back as an Item, and search lists the items in a namespace. Namespaces work like folders: Asha's memories and Ravi's never mix unless you search a shared prefix.
store.put(("memories", "asha"), "contact", {"content": "Wants us to text them"})
print(store.get(("memories", "asha"), "contact").value)
store.delete(("memories", "asha"), "contact")
print(store.get(("memories", "asha"), "contact"))A put to an existing key replaces the value, and delete removes it.
Stores for production
InMemoryStore is lost when the process ends. PostgresStore, from langgraph-checkpoint-postgres, has the same methods and keeps data in PostgreSQL; LangGraph Platform provides one automatically. Code written against the store works with either.
The store is not the checkpointer
LangGraph's checkpointer saves one conversation's state, a thread. The store is shared across threads, which is what makes memory long-term. Lesson 13 uses both.
Try it yourself
- Search
("memories",)and see which items a prefix finds. - Store a nested dictionary and read one field back.
- Print an item's
created_atandupdated_atafter a secondput.
This is what real progress feels like.