Mem0: Long-term Memory for AI Agents

repository·main·Indexed 13 days ago

https://github.com/mem0ai/mem0

An intelligent memory layer designed to enhance AI assistants and agents with personalized, long-term memory. Mem0 allows agents to remember user preferences, adapt to individual needs, and maintain context across sessions. It provides a CLI available for Node.js (18+) and Python (3.10+) to add, search, list, update, and delete memories, featuring a specialized Agent Mode for programmatic consumption in AI tool loops.

Tokens
452.1K
Snippets
1.2K
Records
1.8K
Agent score
98%

What's inside Mem0

  1. Overview of Mem0 Capabilities

    main

    Mem0 provides long-term, persistent, and self-improving memory for AI agents. It allows memory to persist across different sessions, tools, and runs. Developers can use Mem0 in several ways:

    • Mem0 Platform: A managed service where you can get an API key and save/search memories using Python or JavaScript.
    • Coding Agent Integrations: Plugins for tools like Claude Code, Cursor, and Codex to help them remember project context.
    • Framework Integrations: Support for over 22 tools, including LangChain, CrewAI, LlamaIndex, and the Vercel AI SDK.
    • Open Source: A self-hosted version that can be run as a library or a Docker stack on your own infrastructure.
    • Agent Self-Signup: A CLI-driven way for AI agents to create accounts and API keys directly from the terminal without email or a dashboard.
  2. What is the Mem0 Platform

    main

    The Mem0 Platform is a fully managed memory layer designed for AI applications and agents. It provides a way for users to maintain context across different sessions and agents without requiring the developer to manage vector stores, rerankers, or underlying infrastructure.

    Key benefits include:

    • Personalized replies: Memories persist across users and agents, reducing prompt bloat.
    • Zero infrastructure: Mem0 manages the vector store and rerankers automatically.
    • Enterprise-ready: Includes audit logs and workspace governance by default.
  3. Overview of Mem0 Open Source self-hosting features

    main

    Mem0 Open Source provides advanced capabilities for production workloads that extend beyond basic memory storage. These features can be configured via code or YAML to adapt memory behavior for specific application needs.

    Key feature categories include:

    • Advanced Retrieval: Metadata filtering with logical operators and reranking for boosted search relevance.
    • Operational Efficiency: Async memory operations for non-blocking, high-throughput applications.
    • Multimodal Capabilities: Support for processing images, audio, and video memories.
    • Customization: Custom instructions to tailor how facts are extracted from text.
    • Integrations: A REST API for language-agnostic use and OpenAI compatibility for drop-in replacement of chat endpoints.
  4. Overview of Mem0 Rerankers

    main

    Mem0 rerankers are used to rescore vector search hits, allowing agents to surface the most relevant memories. Reranking improves precision but introduces additional latency. It is recommended to establish baseline search performance before implementing reranking to measure the actual uplift in relevance.

    Supported Rerankers

    Mem0 supports five primary reranking providers, available in both Python and TypeScript (self-hosted) SDKs:

    • Cohere: API-first provider for high quality.
    • Zero Entropy: Managed neural reranker designed for production workloads.
    • Sentence Transformers: Self-hosted option using cross-encoder models for on-device reranking.
    • Hugging Face: Self-hosted option for privacy-sensitive deployments.
    • LLM Reranker: Uses LLMs for bespoke scoring logic or complex, custom prompts.
  5. Key features of Mem0

    main

    Mem0 provides several core capabilities for AI memory management:

    • Scoped Memory: Memories can be scoped to a User, Agent, App, or Run (session/conversation), ensuring context is maintained at the correct level.
    • Adaptive Personalization: The system continuously updates memories based on user interactions and feedback.
    • Cost Efficiency: Instead of passing entire conversation transcripts into the LLM context window, Mem0 adds only the most relevant memories, saving token costs.
    • Platform Consistency: Ensures consistent data and behavior across different devices and platforms.
    • Managed Service: Offers a hosted solution for easy deployment.
  6. Supported Vector Databases in Mem0

    main

    Mem0 supports a wide range of vector databases to store and retrieve memory. Support varies between the Python and TypeScript implementations.

    Python Implementation

    Supported databases include:

    • Qdrant
    • Chroma
    • PGVector
    • Upstash Vector
    • Milvus
    • Pinecone
    • MongoDB
    • Oracle AI Vector Search
    • Azure
    • Redis
    • Valkey
    • Elasticsearch
    • OpenSearch
    • Supabase
    • Vertex AI
    • Weaviate
    • FAISS
    • LangChain
    • Amazon S3 Vectors
    • Neptune Analytics
    • Databricks
    • Turbopuffer

    TypeScript Implementation

    Supported databases include:

    • Qdrant
    • Redis
    • PGVector
    • Supabase
    • LangChain
    • Oracle AI Vector Search
    • Azure AI Search
    • Vectorize
    • Amazon S3 Vectors
    • Milvus
    • Neptune Analytics
    • In-memory store
  7. Capabilities of the Mem0 Vercel AI SDK Skill

    main

    Once the skill is installed, Claude can assist with the following tasks in your TypeScript or Next.js projects using the @mem0/vercel-ai-provider package:

    • Project Setup: Automatically set up @mem0/vercel-ai-provider in your codebase.
    • Code Generation: Generate working code using the wrapped model (createMem0) or standalone utilities like retrieveMemories, addMemories, etc.
    • Multi-provider Configuration: Configure setups involving multiple LLM providers (OpenAI, Anthropic, Google, Groq, Cohere).
    • Integration Patterns: Integrate memory into streaming responses, structured outputs, and API routes.
  8. Explore Mem0 Cookbook Examples

    main

    Mem0 provides a variety of cookbooks and tutorials for building stateful AI applications like chatbots, virtual assistants, and agents. These examples cover different implementation patterns, from local self-hosting to complex multi-agent collaborations.

    Core Implementation Patterns (Essentials)

    • Building an AI Companion: Covers the end-to-end core memory lifecycle.
    • Partitioning Memories by Entity: Explains how to scope memories per user, agent, or app to balance personalization with consistent behavior.
    • Controlling Memory Ingestion: Provides techniques to filter speculation and low-confidence data during the ingestion process.

    Specialized Use Cases

    • Companion Playbooks: Includes local setups with Ollama, Node.js implementations, voice-first companions, and specialized assistants (Travel, Tutor, YouTube Research).
    • Ops & Automations: Focuses on workflow integration like automated email intelligence, content creation (tone/style guidelines), and multi-session research agents.
    • Integrations & Platforms: Demonstrates using Mem0 with OpenAI tool calls, AWS Bedrock, Tavily Search, and the Agents SDK.
    • Frameworks & Multimodal: Covers advanced patterns like ReAct agents with LlamaIndex, multi-agent collaboration with shared memory, and visual memory retrieval for multimodal context.
  9. Available Mem0 Integrations Overview

    main

    Mem0 integrates with various AI frameworks, agentic platforms, and observability tools to provide persistent memory, optimized token usage, and consistent context management.

    Agent & Multi-Agent Frameworks

    • AutoGen: Build multi-agent systems with persistent memory.
    • CrewAI: Develop collaborative AI agents with shared memory.
    • Camel AI: Use Mem0Storage to persist multi-agent conversations and share cloud memory.
    • OpenAI Agents SDK: Integrate for persistent memory across multi-agent workflows.
    • Google ADK: Integrate for persistent memory across multi-agent workflows.
    • Agno: Build autonomous agents with memory.
    • ChatDev: Add cloud-managed memory via zero-code YAML configuration.
    • Mastra: Build agents using Mastra's framework and tools.

    LLM Orchestration & RAG Frameworks

    • LangChain: Build powerful agents with memory capabilities.
    • LangChain Tools: Enhance agent capabilities using Mem0.
    • LangGraph: Create complex agent workflows with memory persistence.
    • LlamaIndex: Build RAG applications with Mem0.
    • Dify: Build AI applications with persistent memory.
    • Flowise: Add persistent memory to chatflows in the low-code builder.

    Web & Application SDKs

    • Vercel AI SDK: Build AI-powered applications with memory.
    • Livekit: Integrate with Livekit for voice agents.
    • ElevenLabs: Build voice agents using ElevenLabs Conversational AI.
    • Pipecat: Build conversational AI agents with memory.

    Observability & Infrastructure

    • AgentOps: Monitor and analyze Mem0 operations with AI agent analytics and LLM observability.
    • Respan: Build applications with persistent memory and comprehensive LLM observability.
    • AWS Bedrock: Use with OpenSearch Service for cloud-native persistent semantic memory storage.

    Extensions & Tools

    • Raycast: Mem0 extension for intelligent memory management and retrieval.
  10. Mem0 Dashboard features overview

    main

    The Mem0 dashboard provides several management capabilities once logged in:

    • Requests: Live audit log of API calls (method, path, status, latency).
    • Memories: Browse and filter memories by user_id.
    • Entities: List user_id, agent_id, and run_id owners. Deleting an entity performs a cascade-delete of its memories.
    • API Keys: Create, label, and revoke per-user keys.
    • Configuration: Override runtime LLM and embedder settings (persists in DB, layered over .env).
    • Settings: Manage account profile and password.
  11. Mem0 Dashboard Features

    main

    The Mem0 dashboard provides several management interfaces:

    • Requests: A live audit log of all API calls, including status, latency, and auth mode.
    • Memories: Interface to browse and search stored memories.
    • Entities: View distinct user_id, agent_id, or run_id values and manage cascade-deletes.
    • API Keys: Create, label, and revoke per-user API keys.
    • Configuration: Runtime overrides for LLM and embedder (persists in the app database and layers over .env values).
    • Settings: Account and session controls.
  12. Supported embedding model providers

    main

    Mem0 supports a wide range of embedding model providers to allow customization of memory vectorization.

    Python Implementation: Supports all available embedders.

    TypeScript Implementation: Supports the following specific providers:

    • OpenAI
    • Azure OpenAI
    • AWS Bedrock
    • FastEmbed
    • Google AI
    • Hugging Face
    • Langchain
    • LM Studio
    • Ollama
    • Together
    • Vertex AI