Mem0

Mem0Tools provides intelligent memory management capabilities for agents using the Mem0 memory platform.

Prerequisites

You need to install the mem0ai and openai libraries.

uv pip install agno mem0ai openai

Set MEM0_API_KEY to use the Mem0 Platform. The example Agent uses Agno's default OpenAI model, so it also requires OPENAI_API_KEY. Get the Mem0 key from the Mem0 dashboard.

export MEM0_API_KEY="your_mem0_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"

Without a Mem0 API key, the toolkit runs a local Mem0 Memory instance. Configure it with the config parameter.

Example

The following agent can store and retrieve memories using Mem0:

from agno.agent import Agent
from agno.tools.mem0 import Mem0Tools

agent = Agent(
    instructions=[
        "You are a memory-enhanced assistant that can remember information across conversations",
        "Store important information about users and their preferences",
        "Retrieve relevant memories to provide personalized responses",
        "Manage memory effectively to improve user experience",
    ],
    tools=[Mem0Tools(user_id="user_123")],
)

agent.print_response("Remember that I prefer vegetarian meals and I'm allergic to nuts", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
configOptional[Dict]NoneMem0 configuration dictionary.
api_keyOptional[str]NoneMem0 API key. Uses MEM0_API_KEY if not set.
user_idOptional[str]NoneUser ID for memory operations.
org_idOptional[str]NoneOrganization ID. Uses MEM0_ORG_ID if not set.
project_idOptional[str]NoneProject ID. Uses MEM0_PROJECT_ID if not set.
inferboolTrueEnable automatic memory inference.
enable_add_memoryboolTrueEnable memory addition functionality.
enable_search_memoryboolTrueEnable memory search functionality.
enable_get_all_memoriesboolTrueEnable retrieving all memories functionality.
enable_delete_all_memoriesboolTrueEnable memory deletion functionality.
allboolFalseEnable all tools. Overrides individual enable flags when True.

Toolkit Functions

FunctionDescription
add_memoryStore new memories or information.
search_memorySearch through stored memories using queries.
get_all_memoriesRetrieve all stored memories for the user.
delete_all_memoriesDelete all stored memories for the user.

Platform compatibility and identity

Leave org_id and project_id unset with the current Platform SDK, including the MEM0_ORG_ID and MEM0_PROJECT_ID environment variables. The adapter forwards them to MemoryClient, whose current constructor no longer accepts these arguments.

The example's add_memory operation is supported by the Platform API. The current Agno adapter's search_memory and get_all_memories methods still pass a top-level user_id; the current Mem0 Platform API requires entity filters instead. Use a current MemoryClient call with explicit filters for those reads until the adapter is updated. The adapter also discards pagination metadata from get_all_memories responses.

A constructor user_id takes precedence over RunContext.user_id. Provide one of them for user-scoped operations. The fallback local Memory implementation can still call configured remote models, embedders, and vector stores; it does not imply offline execution.

Developer Resources