Advanced

Studying Production Systems

Mem0 — architecture in depth

0%

complete

6 sections·~3 min read·1 expanded

Mem0's core loop: extract facts from conversation → for each new fact, retrieve top-k similar existing memories → an LLM routing call decides ADD/UPDATE/DELETE/NOOP → store the result in a vector index (and optionally a graph, in the Mem0^g variant, which additionally runs entity/relationship extraction and stores in Neo4j alongside the vector store). This is literally the pattern you built by hand in Modules 5-6 — Mem0 productionizes it with production concerns handled: multi-tenancy, hosted infra, SDKs for a dozen+ frameworks, and an optimized routing algorithm (their 2026 update moved to single-pass hierarchical extraction to cut token cost significantly versus their original 2025 approach).

Zep leans graph-first rather than vector-first: it builds a temporal knowledge graph as its primary structure (Module 6's temporal graph concept, productionized), with vector search as a secondary signal layered on top for semantic fallback. Its pitch is specifically strong performance on complex temporal reasoning benchmarks (LongMemEval) — questions like "what changed between these two points in time" are graph-native questions Zep is built to answer well.

Letta's foundational idea is the OS-memory-paging analogy from Module 4: the LLM's context window is treated like RAM (fast, limited, volatile), and long-term storage is treated like a disk (slower, persistent, effectively unlimited). The agent itself is given explicit tools to "page" information in and out — deciding what to keep in its working context versus what to write out to long-term storage, rather than this being entirely handled by an external routing system.

Cognee's whole pitch is minimal-setup, local-first operation — install via pip, provide an LLM API key, and you have working persistent memory with no external database infrastructure required by default. Its API is deliberately reduced to four verbs: remember, recall, forget, improve — a close cousin of the ADD/UPDATE/DELETE/NOOP pattern, just renamed for clarity, with "improve" covering ongoing refinement/consolidation of stored memories over time.

Supermemory positions itself specifically around MCP-native integration and coding-agent workflows (Claude Code, Cursor, OpenCode plugins) — its differentiation isn't a fundamentally different storage architecture, but tight, frictionless integration into the specific tools developers already use daily, plus benchmark claims (self-reported, not yet independently verified as of the most recent data) on LongMemEval, LoCoMo, and ConvoMem.

# Mem0 hands-on
from mem0 import Memory
m = Memory()
m.add("User is allergic to peanuts", user_id="test_user")
m.add("User's allergy is actually to tree nuts, not peanuts", user_id="test_user")
print(m.search("what allergy does the user have", user_id="test_user"))
# Check: did it correctly UPDATE rather than storing both contradicting facts?
# Cognee hands-on (API shape illustrative — check current docs for exact calls)
import cognee
await cognee.add("User is allergic to peanuts")
await cognee.add("User's allergy is actually to tree nuts, not peanuts")
results = await cognee.search("what allergy does the user have")
print(results)

Run both, on the same contradiction scenario, and write down: did each system correctly resolve the contradiction? How fast was each? How much setup did each require?