Overview
Integrating MemMachine with CrewAI empowers your agents with a persistent memory layer. Unlike standard session memory, this integration allows your crews to remember past interactions, learn user preferences, and maintain deep context across multiple tasks and sessions.Configuration
The integration is primarily managed through environment variables. You can set these in your.env file or export them directly in your shell:
1
Install Dependencies
Install the core CrewAI framework along with the MemMachine client:
2
Initialize Memory Tools
The
create_memmachine_tools helper simplifies the setup. This will return a list of tools that agents can use to add and search their memory.3
Assign Tools to Agents
Pass the
memmachine_tools list to your CrewAI agents. Agents will use these tools automatically when they need to store a new finding or recall a past preference.4
Execute the Crew
Once the agent is equipped with the memory tools, define your tasks and kickoff the crew.
Advanced Usage
Shared Team Memory
If you want multiple agents to share the same knowledge pool, initialize the tools with agroup_id. This is ideal for collaborative agents where a “Writer” needs to recall information stored by a “Researcher.”
Manual Memory Management
For more granular control, you can use theMemMachineTools class directly without the CrewAI agent wrapper.
Pro Tip: Use clear
user_id or session_id identifiers to prevent “memory bleed” between different users or unrelated tasks. Requirements
- MemMachine Server: Must be reachable at the
MEMORY_BACKEND_URL. - Python: 3.10 or higher.
- Framework: CrewAI and
crewai-tools.

