Skip to main content

Overview

Mem0 provides a suite of tools for storing, searching, and retrieving memories, enabling agents to maintain context and learn from past interactions. The tools are built as Langchain tools, making them easily integrable with any AI agent implementation.

Installation

Install the required dependencies:

Authentication

Import the necessary dependencies and initialize the client:

Available Tools

Mem0 provides three main tools for memory management:

1. ADD Memory Tool

The ADD tool allows you to store new memories with associated metadata. It’s particularly useful for saving conversation history and user preferences.

Schema

Implementation

Example Usage

2. SEARCH Memory Tool

The SEARCH tool enables querying stored memories using natural language queries and advanced filtering options.

Schema

Implementation

Example Usage

3. GET_ALL Memory Tool

The GET_ALL tool retrieves all memories matching specified criteria, with support for pagination.

Schema

Implementation

Example Usage

Integration with AI Agents

All tools are implemented as Langchain StructuredTool instances, making them compatible with any AI agent that supports the Langchain tools interface. To use these tools with your agent:
  1. Initialize the tools as shown above
  2. Add the tools to your agent’s toolset
  3. The agent can now use these tools to manage memories through natural language interactions
Each tool provides structured input validation through Pydantic models and returns consistent responses that can be processed by your agent.

LangChain Integration

Build conversational agents with LangChain and Mem0

LangGraph Integration

Create stateful workflows with LangGraph
Enjoying Mem0? Star us on GitHub — it takes two seconds and helps more developers discover open-source memory.