Leveraging memory systems in the CrewAI framework to enhance agent capabilities.
Component | Description |
---|---|
Short-Term Memory | Temporarily stores recent interactions and outcomes using RAG , enabling agents to recall and utilize information relevant to their current context during the current executions. |
Long-Term Memory | Preserves valuable insights and learnings from past executions, allowing agents to build and refine their knowledge over time. |
Entity Memory | Captures and organizes information about entities (people, places, concepts) encountered during tasks, facilitating deeper understanding and relationship mapping. Uses RAG for storing entity information. |
Contextual Memory | Maintains the context of interactions by combining ShortTermMemory , LongTermMemory , and EntityMemory , aiding in the coherence and relevance of agent responses over a sequence of tasks or a conversation. |
appdirs
packageCREWAI_STORAGE_DIR
environment variableappdirs
library to determine storage locations following platform conventions. Here’s exactly where your files are stored:
CREWAI_STORAGE_DIR
to a known location in production for better controlProvider | Best For | Pros | Cons |
---|---|---|---|
OpenAI | General use, reliability | High quality, well-tested | Cost, requires API key |
Ollama | Privacy, cost savings | Free, local, private | Requires local setup |
Google AI | Google ecosystem | Good performance | Requires Google account |
Azure OpenAI | Enterprise, compliance | Enterprise features | Complex setup |
Cohere | Multilingual content | Great language support | Specialized use case |
VoyageAI | Retrieval tasks | Optimized for search | Newer provider |
Feature | Basic Memory | User Memory (Legacy) | External Memory |
---|---|---|---|
Setup Complexity | Simple | Medium | Medium |
Integration | Built-in contextual | Contextual + User-specific | Standalone |
Storage | Local files | Mem0 Cloud/Local | Custom/Mem0 |
Cross-session | ✅ | ✅ | ✅ |
User-specific | ❌ | ✅ | ✅ |
Custom providers | Limited | Mem0 only | Any provider |
Recommended for | Most use cases | Legacy projects | Specialized needs |
CREWAI_STORAGE_DIR
environment variablememory=True
MEM0_API_KEY
environment variable is setmem0ai
package is installedmemory=True
for most use cases (simplest and fastest)Event | Description | Key Properties |
---|---|---|
MemoryQueryStartedEvent | Emitted when a memory query begins | query , limit , score_threshold |
MemoryQueryCompletedEvent | Emitted when a memory query completes successfully | query , results , limit , score_threshold , query_time_ms |
MemoryQueryFailedEvent | Emitted when a memory query fails | query , limit , score_threshold , error |
MemorySaveStartedEvent | Emitted when a memory save operation begins | value , metadata , agent_role |
MemorySaveCompletedEvent | Emitted when a memory save operation completes successfully | value , metadata , agent_role , save_time_ms |
MemorySaveFailedEvent | Emitted when a memory save operation fails | value , metadata , agent_role , error |
MemoryRetrievalStartedEvent | Emitted when memory retrieval for a task prompt starts | task_id |
MemoryRetrievalCompletedEvent | Emitted when memory retrieval completes successfully | task_id , memory_content , retrieval_time_ms |