Overview
- Store and retrieve memories from Mem0 within Agno agents
- Support for multimodal interactions (text and images)
- Semantic search for relevant past conversations
- Personalized responses based on user history
- One-line memory integration via
Mem0Tools
Prerequisites
Before setting up Mem0 with Agno, ensure you have:- Installed the required packages:
- Valid API keys:
- Mem0 API Key
- OpenAI API Key (for the agent model)
Quick Integration (Using Mem0Tools
)
The simplest way to integrate Mem0 with Agno Agents is to use Mem0 as a tool using built-in Mem0Tools
:
- Persistent memory writing:
Mem0Tools
usesMemoryClient.add(...)
to store messages from user-agent interactions, including optional metadata such as user ID or session. - Contextual memory search: Compatible queries use
MemoryClient.search(...)
to retrieve relevant past messages, improving contextual understanding. - Multimodal support: Both text and image inputs are supported, allowing richer memory records.
Mem0Tools
uses theMemoryClient
under the hood and requires no additional setup. You can customize its behavior by modifying your tools list or extending it in code.
Full Manual Example
Note: Mem0 can also be used with Agno Agents as a separate memory layer.The following example demonstrates how to create an Agno agent with Mem0 memory integration, including support for image processing:
Key Features
1. Multimodal Memory Storage
The integration supports storing both text and image data:- Text Storage: Conversation history is saved in a structured format
- Image Analysis: Agents can analyze images and store visual information
- Combined Context: Memory retrieval combines both text and visual data
2. Personalized Agent Responses
Improve your agent’s context awareness:- Memory Retrieval: Semantic search finds relevant past interactions
- User Preferences: Personalize responses based on stored user information
- Continuity: Maintain conversation threads across multiple sessions
3. Flexible Configuration
Customize the integration to your needs:- Use
Mem0Tools()
for drop-in memory support - Use
MemoryClient
directly for advanced control - User Identification: Organize memories by user ID
- Memory Search: Configure search relevance and result count
- Memory Formatting: Support for various OpenAI message formats