Tools · LangChain
LangMem Explained: Long-Term Memory for LangChain
LangMem adds long-term memory extraction and storage to LangChain and LangGraph agents — integrating with checkpoints and stores so LangGraph teams get persistent memory natively.
LangMem pipeline
Definition
What is LangMem?
LangMem is the LangChain ecosystem’s long-term memory layer — a LangGraph memory store with extraction tools for persistent agent facts.
Unlike legacy ConversationBuffer modules, LangMem integrates with LangGraph checkpointers and stores: memories persist across graph invocations and threads. It provides semantic memory search over stored facts — the LangGraph-native answer to “how do I remember users across sessions?”
Mechanism
How LangMem works
Extract memories from agent runs → store in LangGraph store → retrieve on future invocations.
- Agent completes a graph run (conversation, tool use)
- LangMem extraction tools pull salient facts from the run
- Facts stored in LangGraph store (backed by your vector DB choice)
- On next invocation, semantic search retrieves relevant memories
- Memories injected into graph state before LLM call
Threads and checkpoints provide session continuity; LangMem adds cross-session long-term recall on top.
Comparison
LangMem vs Engram vs Zep vs Letta
| Framework | Strength | Best for |
|---|---|---|
| Engram | Weaviate-native, hybrid search | Weaviate shops, managed LTM |
| LangMem | LangGraph native store | LangChain/LangGraph teams |
| Zep | Temporal knowledge graph | CRM, evolving relationships |
| Letta | Core/archival paging | Virtual context, MemGPT pattern |
Decision
When to use LangMem
- Choose LangMem — already on LangGraph; want checkpoint + memory unified; LangChain shop
- Choose Engram — Weaviate infrastructure; managed write pipeline + hybrid search
- Choose Zep — temporal knowledge graph, CRM fact evolution
- Choose Letta — MemGPT paging, virtual context
- Choose Engram or Mem0 — framework-agnostic managed API
Setup
How to add LangMem to an agent
Install langmem → configure LangGraph store → add extraction/retrieval tools to your graph.
- Install
langmemand configure a vector-backed LangGraph store - Add memory extraction tools to post-run hooks
- Add memory search tools to pre-LLM nodes
- Scope by user_id / thread_id in store metadata
- Validate recall@k on your eval set before production
FAQ
Frequently asked questions
LangMem vs LangChain memory modules?
LangChain buffers (ConversationBuffer, Summary) manage in-session history. LangMem adds durable cross-session LTM with extraction and semantic search. See LangChain memory.
LangMem vs Mem0?
LangMem is LangGraph-native. Engram leads for Weaviate-native memory. Mem0 is framework-agnostic managed API. Choose based on your existing infra.
Is LangMem open source?
Yes — part of the LangChain ecosystem. You bring your own vector store backend for the LangGraph store.
Is LangMem production-ready?
Suitable for LangGraph production agents with proper user_id scoping, eval in CI and store ops. Compare Engram/Mem0 for managed pipelines if you want less DIY.
What vector store does LangMem use?
LangGraph store supports multiple backends — Postgres, Redis, custom vector stores. You configure the backing store; LangMem handles extraction and retrieval semantics.
LangMem vs Zep?
LangMem is vector-semantic LTM for LangGraph. Zep adds temporal knowledge graphs with bi-temporal invalidation. Zep LongMemEval +18.5% vs baseline (Rasmussen et al., 2025).
LangMem LongMemEval scores?
LOCOMO J 58.1 in Mem0 paper eval (Chhikara et al., 2025). Mem0 66.9 and Zep 66.0 score higher on the same benchmark.
LangMem for multi-agent systems?
LangGraph shared store with namespace scoping supports multi-agent memory. See multi-agent memory guide.