CrewAI integration
CrewAI agents equipped with Zep’s memory platform can maintain context across conversations, access shared knowledge bases, and make more informed decisions. This integration provides persistent memory storage and intelligent knowledge retrieval for your CrewAI workflows.
Core benefits
- Persistent Memory: Conversations and knowledge persist across sessions
- Context-Aware Agents: Agents automatically retrieve relevant context during execution
- Dual Storage: User-specific memories and shared organizational knowledge
- Intelligent Tools: Search and data addition tools for dynamic knowledge management
Installation
Requires Python 3.10+, CrewAI >=0.80.0, and a Zep Cloud API key. Get your API key from app.getzep.com.
Set up your environment variables:
Storage types
User storage
Use ZepUserStorage
for personal context and conversation history:
User storage automatically routes data:
- Messages (
type: "message"
) → Thread API for conversation context - JSON/Text (
type: "json"
ortype: "text"
) → User Graph for preferences
Graph storage
Use ZepGraphStorage
for organizational knowledge that multiple agents can access:
Tool integration
Equip your agents with Zep tools for dynamic knowledge management:
Tool parameters:
Search tool:
query
: Natural language search querylimit
: Maximum results (default: 10)scope
: Search scope - “edges”, “nodes”, “episodes”, or “all”
Add data tool:
data
: Content to store (text, JSON, or message)data_type
: Explicit type - “text”, “json”, or “message”
Advanced patterns
Structured data with ontologies
Define entity models for better knowledge organization:
Multi-agent with mixed storage
Combine user and graph storage for comprehensive memory:
Research and curation workflow
Agents can search existing knowledge and add new discoveries:
Configuration options
ZepUserStorage parameters
client
: Zep client instance (required)user_id
: User identifier (required)thread_id
: Thread identifier (optional, enables conversation context)mode
: Context mode - “summary” or “raw_messages” (default: “summary”)search_filters
: Filter search results by node labels or attributesfacts_limit
: Maximum facts for context (default: 20)entity_limit
: Maximum entities for context (default: 5)
ZepGraphStorage parameters
client
: Zep client instance (required)graph_id
: Graph identifier (required)search_filters
: Filter by node labels (e.g.,{"node_labels": ["Technology"]}
)facts_limit
: Maximum facts for context (default: 20)entity_limit
: Maximum entities for context (default: 5)
Memory routing
The integration automatically routes different data types to appropriate storage:
Complete example
Here’s a complete example showing personal assistance with conversation memory:
Best practices
Storage selection
- Use ZepUserStorage for personal preferences, conversation history, and user-specific context
- Use ZepGraphStorage for shared knowledge, organizational data, and collaborative information
Memory management
- Set up ontologies for structured data organization
- Use search filters to target specific node types and improve relevance
- Combine storage types for comprehensive memory coverage
Tool usage
- Bind tools to specific users or graphs at creation time
- Use search scope “all” sparingly as it’s more expensive
- Add data with appropriate types (message, json, text) for correct routing
- Limit search results appropriately to avoid context bloat
Next steps
- Explore graph storage patterns for advanced knowledge organization
- Learn about memory management in Zep
- See code examples for additional patterns