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 openaiSet 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
| Parameter | Type | Default | Description |
|---|---|---|---|
config | Optional[Dict] | None | Mem0 configuration dictionary. |
api_key | Optional[str] | None | Mem0 API key. Uses MEM0_API_KEY if not set. |
user_id | Optional[str] | None | User ID for memory operations. |
org_id | Optional[str] | None | Organization ID. Uses MEM0_ORG_ID if not set. |
project_id | Optional[str] | None | Project ID. Uses MEM0_PROJECT_ID if not set. |
infer | bool | True | Enable automatic memory inference. |
enable_add_memory | bool | True | Enable memory addition functionality. |
enable_search_memory | bool | True | Enable memory search functionality. |
enable_get_all_memories | bool | True | Enable retrieving all memories functionality. |
enable_delete_all_memories | bool | True | Enable memory deletion functionality. |
all | bool | False | Enable all tools. Overrides individual enable flags when True. |
Toolkit Functions
| Function | Description |
|---|---|
add_memory | Store new memories or information. |
search_memory | Search through stored memories using queries. |
get_all_memories | Retrieve all stored memories for the user. |
delete_all_memories | Delete 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.