Store and setting use_longterm_memory=True. This enables persistent storage that survives across threads and conversations.
Setup
How it works
When long-term memory is enabled, deep agents maintain two separate filesystems:1. Short-term (transient) filesystem
- Stored in the agent’s state
- Persists only within a single thread
- Files are lost when the thread ends
- Accessed through standard paths:
/notes.txt
2. Long-term (persistent) filesystem
- Stored in a LangGraph Store
- Persists across all threads and conversations
- Files survive indefinitely
- Accessed through the special prefix:
/memories/notes.txt
The /memories/ path convention
The key to long-term memory is the/memories/ path prefix:
- Files with paths starting with
/memories/are stored in the Store (persistent) - Files without this prefix remain in transient state
- All filesystem tools (
ls,read_file,write_file,edit_file) work with both
Cross-thread persistence
Files in/memories/ can be accessed from any thread:
Use cases
User preferences
Store user preferences that persist across sessions:Self-improving instructions
An agent can update its own instructions based on feedback:Knowledge base
Build up knowledge over multiple conversations:Research projects
Maintain research state across sessions:Store implementations
Any LangGraphBaseStore implementation works:
InMemoryStore (development)
Good for testing and development, but data is lost on restart:PostgresStore (production)
For production, use a persistent store:Best practices
Use descriptive paths
Organize long-term files with clear, hierarchical paths:Document what gets persisted
In system prompts, clarify when to use long-term vs short-term storage:Isolate storage by assistant ID
For multi-tenant applications, provide anassistant_id to isolate storage:
Use persistent stores in production
Listing files
Thels tool shows files from both filesystems:
/memories/ in listings.
Limitations
Store is required
You must provide a Store when enabling long-term memory:Agents must use correct paths
The agent must learn to use the/memories/ prefix for persistence. The system prompt teaches this, but the agent must follow the instructions.
No automatic cleanup
Long-term files persist indefinitely. There’s no built-in TTL or automatic cleanup. You’ll need to implement cleanup strategies if needed.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.