Skip to content

CrewAI Plugin: Memory

FloTorch CrewAI Memory services enable persistent memory capabilities for your agents, allowing them to store and retrieve information across sessions. The memory system integrates seamlessly with CrewAI’s dual-memory pattern and provides both short-term and long-term memory implementations to suit different use cases.

Available Memory Types:

  • ExternalMemory - Backed by FlotorchMemoryStorage for long-term persistent storage

Important: Memory services require prior setup in the FloTorch Console. Memory capabilities are not built-in and must be explicitly configured.

Before using FloTorch CrewAI Memory services, ensure you have completed the general prerequisites outlined in the CrewAI Plugin Overview, including installation and environment configuration.

from flotorch.crewai.memory import FlotorchMemoryStorage
from crewai.memory.external.external_memory import ExternalMemory
# Initialize external memory storage (requires prior registration in FloTorch Console)
external_storage = FlotorchMemoryStorage(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
name="your-memory-provider", # Memory provider name from FloTorch Console
user_id="user_123",
app_id="app_123"
)
# Create external memory
external_memory = ExternalMemory(storage=external_storage)
FlotorchMemoryStorage(
api_key: str, # FloTorch API key for authentication (required)
base_url: str, # FloTorch Gateway endpoint URL (required)
name: str, # Memory provider name from FloTorch Console (required)
user_id: str, # User identifier for memory attribution (required)
app_id: str # Application identifier for memory attribution (required)
)

Parameter Details:

  • api_key - Authentication key for accessing FloTorch Gateway (can be set via environment variable)
  • base_url - FloTorch Gateway endpoint URL (can be set via environment variable)
  • name - The name of the memory provider configured in FloTorch Console
  • user_id - User identifier for attributing memories to specific users
  • app_id - Application identifier for organizing memories by application context

External Memory:

  • Provides long-term persistent storage
  • Backed by FloTorch Memory providers
  • Supports user and application-scoped memories
  • Enables knowledge retention across interactions

Memory services provide automatic conversation management:

  • Content Extraction - Automatically extracts content from CrewAI conversations
  • Role Mapping - Converts CrewAI roles to FloTorch-compatible formats
  • Metadata Storage - Stores conversations with associated metadata
  • Tool Call Handling - Manages tool calls and responses within memory
  • Multi-Agent Context - Preserves context across multiple agents in a Crew
  • Task-Based Memory - Maintains memory context for task-based workflows

External Memory Search:

  • Keyword-Based Search - Performs traditional text-based searches
  • User/App Filtering - Filters results by user ID and application name
  • Metadata Filtering - Supports custom metadata filtering
  • Date Range Queries - Allows filtering by time ranges
  • Relevance Scoring - Returns results with relevance scores for ranking
  • Pagination Support - Supports paginated results for large memory sets
from flotorch.crewai.memory import FlotorchMemoryStorage
from crewai.memory.external.external_memory import ExternalMemory
from crewai import Crew
# Initialize external memory
external_storage = FlotorchMemoryStorage(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
name="your-memory-provider",
user_id="user_123",
app_id="app_123"
)
external_memory = ExternalMemory(storage=external_storage)
# Use with CrewAI Crew
crew = Crew(
agents=[agent],
tasks=[task],
external_memory=external_memory,
verbose=True
)
result = crew.kickoff()
from flotorch.crewai.agent import FlotorchCrewAIAgent
from flotorch.crewai.memory import FlotorchMemoryStorage
from crewai.memory.external.external_memory import ExternalMemory
from crewai import Crew
# Create agent with memory enabled
agent_manager = FlotorchCrewAIAgent(
agent_name="customer-support",
enable_memory=True, # Enables memory tools (preload/search)
base_url="https://gateway.flotorch.cloud",
api_key="your_api_key"
)
agent = agent_manager.get_agent()
# Add external memory for long-term storage
external_storage = FlotorchMemoryStorage(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
name="customer-support-memory",
user_id="user_123",
app_id="app_123"
)
external_memory = ExternalMemory(storage=external_storage)
# Use with Crew
crew = Crew(
agents=[agent],
tasks=[task],
external_memory=external_memory,
verbose=True
)
result = crew.kickoff()
  1. Memory Provider Setup - Always configure memory providers in FloTorch Console before using them in code
  2. Memory Type Selection - Use external memory for long-term knowledge retention; use CrewAI’s built-in options for short-term context as needed
  3. User and App IDs - Always provide meaningful user_id and app_id values for proper memory attribution
  4. Error Handling - Implement proper error handling for memory operations in production environments
  5. Memory Scope - Use appropriate memory scoping to avoid memory leaks and ensure proper cleanup
  6. Multi-Agent Memory - Consider memory sharing strategies when multiple agents need access to the same information
  7. Memory Performance - Monitor memory search performance and optimize queries for better response times
  8. Memory Cleanup - Implement proper memory cleanup strategies for long-running applications