LangMem is a toolkit that helps agents learn from their interactions over time. It extracts important information from conversations, refines agent behavior through prompt optimization, and maintains long-term memory across sessions. It provides functional primitives that work with any storage system as well as native integration with LangGraph's long-term memory store, which is available by default in LangGraph Platform deployments.
Memory can be managed in two ways. In the hot path, createmanagememorytool and createsearchmemorytool give the agent tools to record and search memories during a conversation, persisted through a LangGraph BaseStore such as InMemoryStore for development or AsyncPostgresStore for production. In the background, a memory manager extracts, consolidates, and updates knowledge without blocking the conversation. Guides cover semantic memory collections, user profiles, episodic memories, dynamic namespaces, message-history summarization, and use in custom agents or CrewAI.
Features
- Core memory API: storage-agnostic primitives for extracting and updating memories
- Hot-path tools: manage and search memory tools the agent calls during active conversations
- Background memory manager: automatic extraction, consolidation, and updates outside the request path
- Memory types: semantic collections, user profiles, and episodic memories
- Prompt optimization: refine single or multiple prompts from interaction history
- LangGraph store integration: works with InMemoryStore, AsyncPostgresStore, and other BaseStore backends with vector indexing
- Namespaces: dynamic namespaces scope memories per user, organization, or agent
- Short-term memory utilities: summarize message history to manage context length
