Overview
In this guide, we’ll create a CrewAI agent that:- Uses CrewAI to manage AI agents and tasks
- Leverages Mem0 to store and retrieve conversation history
- Creates personalized experiences based on stored user preferences
Setup and Configuration
Install necessary libraries:Newer versions of CrewAI removed the
memory_config={"provider": "mem0"} shortcut on Crew(...) that older guides referenced. CrewAI still offers a native Mem0 path through its ExternalMemory API, so that option remains open; check CrewAI’s memory documentation for the shape your version expects. This guide wires Mem0 in explicitly through MemoryClient instead, which keeps retrieval under your control and stays valid as CrewAI’s memory API changes.Store User Preferences
Set up initial conversation and preferences storage:Retrieve Relevant Memories
Look up what Mem0 already knows about the user before planning a trip, so the crew’s output reflects their actual preferences:Create CrewAI Agent
Define an agent with search capabilities:Define Tasks
Create a task that folds the retrieved memories into its description, so the agent plans around the user’s known preferences:Set Up Crew
Configure the crew. Mem0 handles persistence outside of CrewAI, so the crew itself does not needmemory=True or a memory_config:
Main Execution Function
Implement the main function to run the travel planning system: retrieve context from Mem0, run the crew, then store the new conversation back:Key Features
- Persistent Memory: Uses Mem0 to maintain user preferences and conversation history
- Agent-Based Architecture: Leverages CrewAI’s agent system for task execution
- Search Integration: Includes SerperDev tool for real-world information retrieval
- Personalization: Utilizes stored preferences for tailored recommendations
Benefits
- Persistent Context & Memory: Maintains user preferences and interaction history across sessions
- Flexible & Scalable Design: Easily extendable with new agents, tasks, and capabilities
Conclusion
By combining CrewAI with Mem0, you can create sophisticated AI systems that maintain context and provide personalized experiences while leveraging the power of autonomous agents.AutoGen Integration
Build multi-agent systems with AutoGen and Mem0
LangGraph Integration
Create stateful agent workflows with memory
Using Mem0? Star us on GitHub to help more developers discover memory for AI apps.