====== Agent Memory Frameworks ====== Agent memory frameworks provide persistent, queryable memory infrastructure for AI agents, enabling them to remember user preferences, track conversation history, and build knowledge over time. Unlike simple conversation buffers, these frameworks offer structured storage, semantic retrieval, and temporal reasoning that transform stateless LLM calls into stateful agent systems(([[https://thesequence.substack.com/p/the-sequence-ai-of-the-week-843-the|The Neuron (2026]])). ===== Why Agents Need Memory ===== LLMs are inherently stateless — each API call starts fresh with no knowledge of previous interactions. Memory frameworks solve this by: * **Personalizing** responses based on accumulated user preferences and history * **Maintaining** context across sessions, days, and weeks * **Tracking** how facts evolve over time (temporal reasoning) * **Sharing** knowledge across multiple agents in orchestrated systems * **Reducing** token costs by storing and retrieving only relevant context * **Enabling persistent memory resumption** — allowing AI agents to resume long-running jobs with prior context intact, remembering user preferences, prior corrections, and task state without requiring manual re-prompting(([[https://www.rohan-paul.com/p/[[claude|claude]]))-opus-47-launched-as-less-powerful|Rohan's Bytes (2026]])). Memory frameworks are particularly critical for tool-using agents that interact with external tools, APIs, and applications, as they maintain context and state across these interactions(([[https://tldr.tech/ai/2026-04-27|TLDR AI - Tool-Using Agents (2026]])). This capability allows AI agents to retain and build upon contextual information across multiple interactions, enabling more sophisticated and context-aware autonomous behaviors(([[https://tldr.tech/ai/2026-04-27|TLDR AI (2026]])). Major AI providers including Anthropic have introduced agent memory capabilities such as Claude Agent Memory, enabling Claude-powered agents to maintain persistent context and memory for more sophisticated autonomous operations(([[https://tldr.tech/ai/2026-04-27|TLDR AI, 2026]])). ===== Framework Comparison ===== | **Framework** | **Architecture** | **Key Strength** | **Best For** | | [[https://mem0.ai|Mem0]] | Vector + Knowledge Graph | Most widely adopted, flexible backends | General-purpose [[agent_personalization|agent personalization]] | | [[https://www.getzep.com|Zep / Graphiti]] | Temporal Knowledge Graph | Fact evolution tracking, <200ms retrieval | Temporal reasoning, compliance (SOC2/HIPAA) | | [[https://www.letta.com|Letta (MemGPT)]] | Three-tier OS-inspired | Agent-controlled self-editing memory | Agents managing their own context | | [[https://[[github|github]].com/[[langchain|langchain]]-ai/langmem|LangMem]] | Flat key-value + vector | Deep [[langgraph|LangGraph]] integration, MIT license | LangGraph-native agent systems | | [[https://[[github|github]].com/getmetal/motorhead|Motorhead]] | Redis-backed server | Simple REST API, session management | Lightweight memory for prototypes | ===== Architecture Deep Dives ===== ==== Mem0 ==== Mem0 uses a dual-store architecture combining vector databases ([[qdrant|Qdrant]], Chroma, [[milvus|Milvus]], [[pgvector|pgvector]]) with [[knowledge_graphs|knowledge graphs]]. An extraction pipeline converts conversations into atomic memory facts scoped to users, sessions, or agents.((Mem0 Documentation. [[https://mem0.ai|mem0.ai]])) ==== Zep / Graphiti ==== Zep implements a temporal knowledge graph that tracks how facts change over time. It scores 63.8% on the LongMemEval benchmark with sub-200ms retrieval latency. Offers Python, TypeScript, and Go SDKs with SOC2 Type 2 and HIPAA compliance.((Zep Documentation. [[https://www.getzep.com|getzep.com]])) ==== Letta (MemGPT) ==== Letta uses a three-tier memory hierarchy inspired by operating systems:((Letta (MemGPT) Documentation. [[https://www.letta.com|letta.com]])) * **Core memory** — Always in the LLM context window (like RAM) * **Recall memory** — Searchable conversation history (like disk cache) * **Archival memory** — Long-term queryable storage (like cold storage) Agents actively self-edit their memory blocks, deciding what stays in context versus what gets archived. ==== LangMem ==== LangMem uses a flat key-value plus vector architecture with MIT licensing and deep [[langgraph|LangGraph]] integration. Unique features include prompt optimization from conversation data and a background memory manager for automatic extraction. ===== Example: Memory-Enhanced Agent ===== from [[mem0|mem0]] import Memory Initialize memory with user scoping memory = Memory() def memory_agent(user_id: str, message: str, llm_client): # Retrieve relevant memories for this user relevant = memory.search(query=message, user_id=user_id, limit=5) memory_context = "\n".join(m["memory"] for m in relevant) # Generate response with memory context response = llm_client.chat( messages=[ {"role": "system", "content": f"User memories:\n{memory_context}"}, {"role": "user", "content": message} ] ) # Store new memories from this interaction memory.add( messages=[ {"role": "user", "content": message}, {"role": "assistant", "content": response} ], user_id=user_id ) return response Memories persist across sessions memory_agent("user_123", "I prefer Python over JavaScript") Later session... memory_agent("user_123", "What language should I use for this project?") Agent recalls the user's Python preference ===== Selection Criteria ===== * **Choose [[mem0|Mem0]]** when you need battle-tested, widely-adopted memory with flexible backend options and multi-agent knowledge sharing * **Choose Zep** when temporal reasoning is critical — tracking how facts evolve over time — and you need enterprise compliance * **Choose [[letta|Letta]]** when agents need active control over their own memory management and dynamic context curation * **Choose LangMem** when you are committed to the [[langgraph|LangGraph]] ecosystem and want cost-free, fully-owned memory infrastructure * **Choose Motorhead** for lightweight prototyping where a simple REST API with Redis-backed sessions is sufficient ===== Benchmarks ===== The **LongMemEval** benchmark measures [[long_term_memory|long-term memory]] capabilities:((Vectorize. "Best AI Agent Memory Systems." [[https://vectorize.io/articles/best-ai-agent-memory-systems|vectorize.io]])) * Cognee: 81.6% (highest score, vector + knowledge graph with built-in RAG) * Zep/Graphiti: 63.8% (best temporal reasoning) * [[mem0|Mem0]] and [[letta|Letta]]: Strong but lack published benchmark scores ===== See Also ===== * [[how_to_add_memory_to_an_agent|How to Add Memory to an Agent]] * [[long_term_memory|Long-Term Memory]] * [[file_system_memory|File System-Based Memory for Agents]] * [[memory_retention|Memory Retention]] * [[agent_memory_persistence|Agent Memory Persistence]] ===== References =====