LangMem
ActiveDescription
LangMem is LangChain's memory layer for agents, helping developers add long-term memory, replay summaries, and context management to improve multi-turn performance.
Key Features
- Core memory API that works with any storage system for flexible agent memory
- Hot-path memory tools agents use to record and search during active conversations
- Background memory manager that auto-extracts, consolidates, and updates knowledge
- Native LangGraph integration with Long-term Memory Store in all Platform deployments
- Seamless cross-session personalization and consistent agent behavior
- OpenAI embeddings support for semantic similarity search across memories
Use Cases
Categories
Quick Start
1. Install: pip install -U langmem
2. Set API key: export ANTHROPIC_API_KEY='sk-...'
3. Create store: store = InMemoryStore(index={'dims': 1536, 'embed': 'openai:text-embedding-3-small'})
4. Add memory tools to your agent via create_manage_memory_tool and create_search_memory_tool
5. Agent automatically stores and retrieves memories during conversations