CrewAI Plugin: Memory
Overview
Section titled “Overview”FloTorch integrates with CrewAI’s dual-memory pattern:
- Short-term conversation context via
ShortTermMemory
backed byFlotorchCrewAISession
storage - Long-term, persistent external memory via
ExternalMemory
backed byFlotorchMemoryStorage
from flotorch.crewai.sessions import FlotorchCrewAISessionfrom flotorch.crewai.memory import FlotorchMemoryStoragefrom crewai.memory.short_term.short_term_memory import ShortTermMemoryfrom crewai.memory.external.external_memory import ExternalMemory
API_KEY = "<your_api_key>"BASE_URL = "https://gateway.flotorch.cloud"PROVIDER = "<flotorch_memory_provider>" # configured in FloTorch ConsoleUSER_ID = "user_123"APP_ID = "app_123"
Memory setup
Section titled “Memory setup”Short-term memory (conversation context)
Section titled “Short-term memory (conversation context)”short_term_storage = FlotorchCrewAISession( api_key=API_KEY, base_url=BASE_URL,)
short_term_memory = ShortTermMemory(storage=short_term_storage)
External memory (long-term persistence)
Section titled “External memory (long-term persistence)”external_storage = FlotorchMemoryStorage( api_key=API_KEY, base_url=BASE_URL, name=PROVIDER, user_id=USER_ID, app_id=APP_ID,)
external_memory = ExternalMemory(storage=external_storage)
Features
Section titled “Features”CrewAI Integration
Section titled “CrewAI Integration”- Uses CrewAI-native
ShortTermMemory
andExternalMemory
- Short-term storage backed by FloTorch Sessions; external storage backed by FloTorch Memory
- Automatic content extraction and robust error handling
Usage Example
Section titled “Usage Example”from crewai import Crew
crew = Crew( agents=[agent], tasks=[task], short_term_memory=short_term_memory, external_memory=external_memory, verbose=True,)
- Requires a configured Memory Provider in FloTorch Console
- Use
short_term_memory
andexternal_memory
parameters onCrew
- Ensure
user_id
andapp_id
are set for external memory attribution