Skip to main content
Long-term memory lets your agent store and recall information across different conversations and sessions. Unlike short-term memory, which is scoped to a single thread, long-term memory persists across threads and can be recalled at any time. Long-term memory is built on LangGraph stores, which save data as JSON documents organized by namespace and key.

Usage

To add long-term memory to an agent, create a store and pass it to create_agent:
Tools can then read from and write to the store using the runtime.store parameter. See Read long-term memory in tools and Write long-term memory from tools for examples.
For a deeper dive into memory types (semantic, episodic, procedural) and strategies for writing memories, see the Memory conceptual guide.

Memory storage

LangGraph stores long-term memories as JSON documents in a store. Each memory is organized under a custom namespace (similar to a folder) and a distinct key (like a file name). Namespaces often include user or org IDs or other labels that makes it easier to organize information. This structure enables hierarchical organization of memories. Cross-namespace searching is then supported through content filters.
For more information about the memory store, see the Persistence guide.

Read long-term memory in tools

Write long-term memory from tools