Mem0: Universal Memory Layer for AI Agents with 61.4k+ GitHub Stars

AI agents are becoming smarter, but they're still forgetting everything. Every conversation resets. Every session starts from scratch. Users repeat context. Agents reprocess the same information. This is where Mem0 changes the game—a universal memory layer that gives AI agents persistent, self-improving memory across sessions. With 61.4k+ GitHub stars and active development (commits within hours), Mem0 is rapidly becoming the standard for building agents that actually remember.

What is Mem0?

Mem0 (pronounced "mem-zero") is an open-source memory layer designed to enhance AI assistants and agents with intelligent, persistent memory. Created by a team backed by Y Combinator (S24) and $24M in Series A funding, Mem0 solves a fundamental problem: AI agents lack long-term context. Without memory, every interaction is isolated. With Mem0, agents store user preferences, recall past conversations, and continuously learn over time.

The project is maintained by the Mem0 team and has grown into a production-ready platform with both open-source and managed cloud options. It supports Python, TypeScript/JavaScript, and integrates seamlessly with popular frameworks like LangChain, CrewAI, Vercel AI SDK, and more. The architecture is designed for scale—handling millions of memories while maintaining sub-second retrieval latency.

What makes Mem0 unique is its focus on personalized AI. Rather than treating every user interaction as a new problem, Mem0 enables agents to build a knowledge graph of user preferences, behavioral patterns, and historical context. This transforms single-interaction tools into adaptive systems that improve with every conversation.

Core Features and Architecture

Multi-Level Memory Hierarchy

Mem0 implements three levels of memory that mirror how humans organize information:

  • User-level memory: Persistent context tied to individuals across all sessions. Communication preferences, technical background, and recurring needs stay accessible regardless of conversation scope.
  • Session-level memory: Task-specific details within isolated threads. Context relevant to one debugging conversation doesn't bleed into unrelated discussions.
  • Agent-level memory: System-wide information independent of individual users. Operational rules, shared knowledge bases, or cross-user insights live here for collective access.

Three Types of Memory Storage

Mem0 distinguishes between episodic, semantic, and procedural memory—each serving different purposes:

  • Episodic memory: Stores interaction-specific events with temporal markers. "User requested API documentation for webhook setup on July 15" includes when and what happened.
  • Semantic memory: Holds extracted knowledge without event context. "User codes in TypeScript" or "prefers async/await" generalizes across interactions.
  • Procedural memory: Encodes behavioral patterns. The agent learns which code formatting the user expects or how to structure multi-step responses.

Hybrid Retrieval Architecture

Mem0's April 2026 algorithm update introduced a breakthrough in memory efficiency. The new system combines:

  • Semantic search: Vector embeddings find conceptually similar memories.
  • BM25 keyword matching: Exact phrase retrieval for precise fact lookup.
  • Entity linking: Entities are extracted, embedded, and linked across memories for retrieval boosting.
  • Temporal reasoning: Time-aware retrieval that ranks the right dated instance for queries about current state, past events, and upcoming plans.

Benchmarks show dramatic improvements: 92.5 on LoCoMo (+21 points), 94.4 on LongMemEval (+27 points), and 64.1 on BEAM at 1M tokens—all with single-pass retrieval and no agentic loops.

Developer-Friendly API

Mem0's API is intentionally simple. Initialize the memory client, call add() to store facts, and search() to retrieve context. The library handles embedding, vector storage, and retrieval logic automatically. Support for multiple LLMs (OpenAI, Anthropic, Ollama, local models) and embedding providers means you're not locked into a single vendor.

Production-Ready Deployment Options

Mem0 offers three deployment paths:

  • Library (pip/npm): For testing and prototyping. Lightweight, no infrastructure overhead.
  • Self-hosted server: Docker-based deployment with dashboard, auth, and API keys. Full control over data and infrastructure.
  • Cloud platform: Zero-ops managed service with SOC 2 compliance, encryption, and audit logging pre-configured.

Get free AI agent insights weekly

Join our community of builders exploring the latest in AI agents, frameworks, and automation tools.

Join Free

Getting Started

Installation:

pip install mem0ai
# For enhanced hybrid search with NLP support:
pip install mem0ai[nlp]
python -m spacy download en_core_web_sm

Basic usage:

from openai import OpenAI
from mem0 import Memory

openai_client = OpenAI()
memory = Memory()

def chat_with_memories(message: str, user_id: str = "default_user") -> str:
    # Retrieve relevant memories
    relevant_memories = memory.search(query=message, filters={"user_id": user_id}, top_k=3)
    memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])

    # Generate response with memory context
    system_prompt = f"You are a helpful AI. Answer based on query and memories.\nUser Memories:\n{memories_str}"
    messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
    response = openai_client.chat.completions.create(model="gpt-5-mini", messages=messages)
    assistant_response = response.choices[0].message.content

    # Store new memories from conversation
    messages.append({"role": "assistant", "content": assistant_response})
    memory.add(messages, user_id=user_id)

    return assistant_response

CLI quickstart (no code required):

npm install -g @mem0/cli
mem0 init --agent --agent-caller claude-code
mem0 add "I prefer dark mode and vim keybindings"
mem0 search "What are my preferences?"

Real-World Use Cases

Customer Support Agents: Recall past tickets, previous issues, and customer preferences. Instead of asking "Have we discussed this before?", the agent already knows the customer's history and can provide contextual, personalized support without forcing users to repeat themselves.

AI Coding Assistants: Mem0 integrates with Claude Code, Cursor, Codex, and Windsurf. The agent remembers your coding style, preferred libraries, project structure, and past debugging sessions. This enables truly personalized code generation that adapts to your workflow.

Healthcare and Wellness: Track patient preferences, medication history, and treatment outcomes. Personalized health assistants can provide recommendations based on accumulated patient data while maintaining HIPAA compliance through encryption and access controls.

Productivity and Learning: Build adaptive tutoring systems that remember student learning patterns, misconceptions, and progress. Personalized productivity assistants that learn your workflow, preferences, and goals improve recommendations over time.

How It Compares

Mem0 vs. Context Windows: Large context windows (100K+ tokens) seem like a memory solution but they're not. Sending full conversation history with every request increases latency and token costs without solving the core problem. Agents reprocess the same information repeatedly instead of storing it once. Mem0 extracts and persists facts, then retrieves only what's needed—reducing costs by ~90% and latency by ~91%.

Mem0 vs. RAG (Retrieval-Augmented Generation): RAG retrieves information from static knowledge bases (documentation, articles, reference material). Mem0 stores user-specific facts that evolve with each conversation. Production agents typically need both: RAG for domain expertise, Mem0 for personalization.

Mem0 vs. LangChain Memory: LangChain provides basic memory abstractions but lacks the sophisticated retrieval, filtering, and lifecycle management that Mem0 offers. Mem0's hybrid search (semantic + keyword + entity + temporal) outperforms simple vector similarity. Mem0 also handles compliance, audit logging, and multi-user scenarios that LangChain leaves to developers.

What's Next

Mem0's roadmap reflects the evolving needs of production AI systems. The team is expanding integrations with emerging frameworks, improving multi-agent coordination, and adding advanced features like graph-based memory for complex relationship tracking. The April 2026 algorithm update demonstrated their commitment to research-backed improvements—benchmarks show 92.5 on LoCoMo, a 21-point improvement over the previous version.

The community is growing rapidly. With 389 contributors, 2,499 commits, and active development (commits within hours of this writing), Mem0 is becoming the de facto standard for persistent memory in AI agents. As agents move from experimental to production, memory becomes non-negotiable. Mem0 is positioned to be the infrastructure layer that makes this transition possible.

Sources