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

1
Extract
2
Store
3
Retrieve
4
Inject

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?”

LangChain memory

Mechanism

How LangMem works

Extract memories from agent runs → store in LangGraph store → retrieve on future invocations.

  1. Agent completes a graph run (conversation, tool use)
  2. LangMem extraction tools pull salient facts from the run
  3. Facts stored in LangGraph store (backed by your vector DB choice)
  4. On next invocation, semantic search retrieves relevant memories
  5. Memories injected into graph state before LLM call

Threads and checkpoints provide session continuity; LangMem adds cross-session long-term recall on top.

Add memory to an AI agent

Comparison

LangMem vs Engram vs Zep vs Letta

FrameworkStrengthBest for
EngramWeaviate-native, hybrid searchWeaviate shops, managed LTM
LangMemLangGraph native storeLangChain/LangGraph teams
ZepTemporal knowledge graphCRM, evolving relationships
LettaCore/archival pagingVirtual context, MemGPT pattern

Best AI memory tools

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

Engram explained · Zep alternatives

Setup

How to add LangMem to an agent

Install langmem → configure LangGraph store → add extraction/retrieval tools to your graph.

  1. Install langmem and configure a vector-backed LangGraph store
  2. Add memory extraction tools to post-run hooks
  3. Add memory search tools to pre-LLM nodes
  4. Scope by user_id / thread_id in store metadata
  5. Validate recall@k on your eval set before production

Build long-term memory

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.