(Updated )
Open-Source AI Memory Layers for Production Agents in 2026: Zep, Letta, mem0 Compared
Production AI agents need memory beyond the context window. Compare Zep, Letta, and mem0 across architecture, latency, self-hosting, and audit trails.
By Craig Hunt
Fractional CTO, Sagecrest Solutions
Production AI agents fail predictably when they forget. The flagship context window handles a single long conversation, then collapses across sessions, users, and days. Memory layers solve this problem by persisting facts the agent learns, retrieving them on demand, and feeding the model only the slices that matter for the next turn.
As a fractional CTO, I watch three open-source memory layers dominate the conversation in mid-2026: Zep, Letta (formerly MemGPT), and mem0. This guide compares them across architecture, production concerns, and team fit.
Why AI Memory Layers Matter
Context windows hit a ceiling fast. A 200K-token window covers roughly 300 single-spaced pages, and naive replay of full conversation history every turn drives token costs up sharply across a heavy-use deployment. Worse, recall accuracy degrades inside long contexts; models lose track of facts buried in the middle of a 150K-token prompt.
Memory layers solve four production problems at once:
- Persistence across sessions. The agent remembers what a user shared last week without replaying the transcript.
- Personalization at scale. Each user sees responses that draw on their own history, not a generic baseline.
- Token-cost reduction. Replaying selective memory cuts token consumption substantially at production volume compared with replaying full history.
- Compliance traceability. Auditors see what the agent remembered, when, and why.
Production agents that skip a memory layer typically pay for it later in token bills, accuracy regressions, or compliance gaps. The architecture choice deserves attention up front.
Quick Comparison Table
| Layer | Memory type | Architecture | Hosting | Pricing | SDKs | License |
|---|---|---|---|---|---|---|
| Zep | Knowledge graph + hybrid search | Service + graph DB | Cloud; self-host via Graphiti | Graphiti free OSS, Cloud usage-based | Python, TypeScript, Go | Graphiti: Apache 2.0 |
| Letta | Block-based agent memory | Stateful server | Self-host + Cloud | Free OSS, Cloud paid tier | Python, TypeScript | Apache 2.0 |
| mem0 | Vector personalization | API + library | Self-host + Cloud | Free OSS, Cloud usage-based | Python, TypeScript | Apache 2.0 |
Zep Deep Dive
Zep treats memory as a temporal knowledge graph. The platform extracts entities, relationships, and facts from each conversation, then stores them in a graph that tracks how facts change over time. When the agent asks for context about a user, Zep returns a coherent summary that respects the latest known state of each fact rather than the raw transcript.
Hybrid search combines semantic similarity with graph traversal. Need everything the user mentioned about pricing concerns AND everything related to their account upgrade? Zep returns both the semantic match and the graph-linked context in one call. Few vector-only layers handle this cleanly.
Zep stopped maintaining its Community Edition on April 2, 2025. The team operates Zep Cloud at getzep.com with usage-based pricing for teams that prefer managed infrastructure. Teams that need to self-host run Graphiti, the Apache 2.0 open-source framework behind Zep’s graph, on a supported graph database such as Neo4j, FalkorDB, or Amazon Neptune, which adds operational weight in exchange for graph capability.
Letta (formerly MemGPT) Deep Dive
Letta evolved from the MemGPT research project at UC Berkeley. The team renamed and productized the system at letta.com while keeping the core insight: agents need a tiered memory hierarchy that mirrors how operating systems manage RAM and disk.
The platform exposes memory as blocks. A persona block describes the agent itself. A human block describes the user. Custom blocks store arbitrary state the agent reads and writes directly through tool calls. Letta runs a stateful server architecture, which preserves agent state across restarts and lets long-lived agents accumulate memory over months.
Letta no longer actively maintains its self-hosted Docker image and points teams to local mode in the Letta app or CLI, or to the Letta App Server for custom applications. Letta Cloud handles the same architecture without the operational overhead. The block model gives engineers a clear mental model of what the agent knows and how memory mutates, which simplifies debugging compared with opaque vector retrieval.
mem0 Deep Dive
mem0 lands at the personalization end of the spectrum. The library extracts user preferences, facts, and behavioral patterns from chat turns, then stores them as vector embeddings keyed to a user ID. On retrieval, mem0 returns the top-K most relevant memories for the current query.
The team operates a managed cloud at mem0.ai that abstracts the vector backend (OpenSearch, Qdrant, or Pinecone) entirely. Self-hosted mem0 ships under Apache 2.0; teams typically pair it with Qdrant or pgvector. Fast onboarding stands out as mem0’s strongest selling point. A Python developer can wire personalization into an existing chatbot inside an afternoon.
mem0 trades graph reasoning for operational simplicity. The right call when the workload reduces to similarity-based recall; the wrong call when the agent must reason about evolving relationships.
How They Compare on Production Concerns
Architecture
Zep models memory as a temporal knowledge graph. Letta models memory as discrete blocks the agent reads and writes. mem0 models memory as vector embeddings indexed by user. The choice depends on what the agent needs to recall: relationships (graph), structured state (blocks), or similarity (vectors).
Latency
All three layers add latency on top of the LLM call. Zep’s graph queries typically land in 50-200ms for well-tuned deployments. Letta’s block reads run faster, often under 50ms, because the server keeps state in memory. mem0’s vector lookups land in 30-100ms depending on the backend.
Educated speculation: The specific latency ranges above reflect commonly cited public benchmarks rather than measured production numbers. Configuration, backend choice, and workload pattern dominate the real-world result. Production teams should benchmark against their own workload before quoting any range internally.
Self-Hosting Complexity
Zep’s approach self-hosts through Graphiti, which requires a supported graph database such as Neo4j, FalkorDB, or Amazon Neptune and adds operational weight. Letta’s Docker image, which runs on Postgres with pgvector, no longer counts as an actively maintained product surface, so Letta points self-hosters to local mode in the Letta app or CLI, or to the Letta App Server. mem0 self-hosts as a Python library that connects to a vector store of choice. mem0 wins on operational simplicity; Letta sits in the middle; Zep demands the most ops investment in exchange for graph capability.
Multi-Tenancy
All three support multi-tenancy through user-scoped namespaces. Zep partitions data by user and session ID natively. Letta isolates agents per workspace. mem0 keys all memory by user ID at the API layer. Production teams serving thousands of end-users should verify quota and isolation guarantees against their own SLAs; defaults vary across releases.
Token-Cost Savings
Versus replaying full conversation history, all three layers cut token consumption substantially in production deployments (commonly cited ranges of 70-95% savings appear across vendor case studies). Zep’s own paper reports LongMemEval accuracy for its graph-based memory of 63.8% overall with gpt-4o-mini and 71.2% with GPT-4o, including 62.4% on temporal-reasoning questions with GPT-4o. Mem0’s own self-reported results claim 94.4% at approximately 6,787 tokens per query on personalization workloads. Zep’s summarization tends to produce the most compact context. mem0’s top-K retrieval offers the most predictable token budget. Letta’s block reads give the agent direct control over what enters context.
Educated speculation: Token-cost savings of 70-95% pull from vendor case studies rather than a single authoritative source. The accurate framing: savings depend heavily on session length, recall density, and routing logic. Run a 30-day instrumented pilot before quoting savings to your CFO.
Sources: Zep, “Zep: A Temporal Knowledge Graph Architecture for Agent Memory” (arXiv 2501.13956); mem0 self-reported results.
Audit and Explainability
Compliance review demands traceability: what did the agent know, when, and why? Zep wins on audit because the temporal graph records each fact’s provenance and update history. Letta surfaces memory blocks the operator can inspect directly through the admin UI. mem0 returns the source chat turns alongside each memory, which gives auditors a clean trail. Regulated industries lean toward Zep or Letta for this reason.
When Zep Wins
- The agent needs to track entities and relationships, not just text similarity (a sales agent tracking deal stages across multiple stakeholders).
- The use case benefits from temporal awareness, meaning the agent must know that user preferences changed last Tuesday.
- Compliance requires fact-level provenance and explainability.
- Hybrid search (semantic plus graph traversal) outperforms vector-only retrieval for the workload.
- The team accepts graph database operational complexity (Neo4j, FalkorDB, or Amazon Neptune through Graphiti) in exchange for graph capability, or runs Zep Cloud.
When Letta Wins
- The team wants explicit control over what enters and leaves agent memory; the block hierarchy makes this surgical.
- The agent runs as a long-lived process that accumulates memory over weeks or months.
- The team runs agents locally through the Letta app or CLI, or builds custom applications on the Letta App Server.
- The team values continuity with the MemGPT research line and academic literature.
- The use case demands fine-grained memory tiering (working memory versus archival).
When mem0 Wins
- The team needs fast personalization rollout, not a full agent architecture redesign.
- Vector simplicity matches the use case; the workload reduces to similarity-based recall.
- The team prefers managed cloud over self-hosted infrastructure.
- The integration target already runs on a vector database (Qdrant, Pinecone, pgvector).
- The product roadmap requires shipping in days, not weeks.
Recommendation
Startups testing personalization: mem0 wins on speed. A two-person team adds personalization to an existing chatbot in an afternoon and ships to production the same week. Plan to revisit the choice once usage justifies graph or block architecture, but ship the lighter layer first.
Mid-market SaaS adding chat memory: Letta strikes the best balance. The block model gives engineers clear mental models of memory state. The stateful server architecture simplifies operations. Add Zep later if the use case grows into entity-relationship territory.
Regulated enterprises needing self-host plus audit: Graphiti, the open-source framework behind Zep, deserves serious evaluation, since Zep no longer maintains a self-hosted Community Edition. Graphiti’s temporal knowledge graph and hybrid retrieval (semantic, keyword, and graph traversal) match what compliance teams demand. Plan for graph database operational overhead; the audit and explainability properties justify the investment for regulated workloads.
The universal lesson: pick the memory layer that fits the use case today, build the application interface to abstract memory access, and stay ready to swap layers later as scale or compliance demands shift.
Frequently Asked Questions
Do I need a memory layer?
If the agent serves the same user across more than one session, yes. If every session opens cold and ends within the context window, no. The break-even point arrives sooner than most teams expect; even a 30-minute support conversation pushes context windows hard.
Can I extend the context window instead?
Frontier models now offer 1M+ token windows, but cost and recall accuracy both degrade at scale. Recent research shows recall accuracy drops sharply for facts buried in the middle of very long contexts. Memory layers solve the recall problem and the token-cost problem at the same time.
How does memory differ from RAG?
RAG retrieves from a static knowledge base built independently of the conversation. Memory captures what the agent learned during prior sessions with specific users. Production agents typically use both: RAG for product knowledge, memory for user-specific context.
Do these layers run production-grade today?
All three ship at production scale today. Zep and Letta both come from teams with multiple years of operational experience. mem0’s Apache 2.0 release dates to 2024 and has accumulated significant production deployments. None match the operational maturity of a mature vector or graph database; teams should expect to invest in observability and runbooks.
What about vendor lock-in?
Letta and mem0 publish Apache 2.0 code, and Zep users can self-host the Apache 2.0 Graphiti framework, which limits lock-in materially. Memory schemas differ across platforms, so migration requires data transformation. Teams that prioritize portability should design their application layer to abstract memory access behind a thin interface, which lets them swap implementations later.
How do these compare to closed-source memory APIs?
Closed-source options such as Anthropic’s MCP-based memory offer integration convenience but tie the team to a single model vendor. Open-source layers preserve model portability, which matters when teams migrate between Claude, GPT-4.1, or Gemini for cost or capability reasons.
Related Guides
- Best AI Agent Memory Tools 2026: broader survey including closed-source and hybrid memory options
- Best Enterprise RAG Platforms 2026: retrieval architecture for static knowledge bases
- Best LLM Observability Tools 2026: tracing and monitoring that pairs with memory-layer deployments
I write from a fractional CTO’s perspective. This review reflects industry research rather than vendor briefings. Some links may earn a commission. See the about page for details.
Get more like this.
Weekly AI tool reviews and practical implementation guides, delivered straight to your inbox.
No spam. Unsubscribe anytime.