Skip to content

AutoGen Plugin: Memory

FloTorch AutoGen Memory services enable persistent memory capabilities for your agents, allowing them to store and retrieve information across sessions. The memory system integrates seamlessly with Microsoft AutoGen’s agent framework and provides long-term persistent storage for external memory.

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

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

from flotorch.autogen.memory import FlotorchAutogenMemory
from autogen_core.memory import MemoryContent, MemoryMimeType
# Initialize memory service (requires prior registration in FloTorch Console)
external_memory = FlotorchAutogenMemory(
name="your-memory-provider",
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
user_id="user_123",
app_id="app_123"
)

Configure your memory service with the following parameters:

FlotorchAutogenMemory(
name: str, # Memory provider name (from FloTorch Console) - required
api_key: str, # FloTorch API key for authentication (required)
base_url: str, # FloTorch Gateway URL (required)
user_id: str, # User identifier for memory isolation (required)
app_id: str # Application identifier for memory isolation (required)
)

Parameter Details:

  • name - The name of the memory provider configured in FloTorch Console
  • 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)
  • user_id - User identifier for isolating memory per user
  • app_id - Application identifier for isolating memory per application

Memory service provides automatic content management:

  • Content Extraction - Automatically extracts content from AutoGen messages
  • MIME Type Support - Supports various content types (TEXT, JSON, etc.)
  • Metadata Storage - Stores conversations with associated metadata
  • Message Handling - Manages text messages and tool responses

Provides comprehensive 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
from flotorch.autogen.agent import FlotorchAutogenAgent
from flotorch.autogen.memory import FlotorchAutogenMemory
from autogen_core.memory import MemoryContent, MemoryMimeType
# Initialize memory service
external_memory = FlotorchAutogenMemory(
name="your-memory-provider",
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
user_id="user_123",
app_id="app_123"
)
# Use with agent
agent_manager = FlotorchAutogenAgent(
agent_name="customer-support",
memory=[external_memory], # Add external memory
base_url="https://gateway.flotorch.cloud",
api_key="your_api_key"
)
agent = agent_manager.get_agent()
from flotorch.autogen.memory import FlotorchAutogenMemory
from autogen_core.memory import MemoryContent, MemoryMimeType
# Initialize memory service
external_memory = FlotorchAutogenMemory(
name="your-memory-provider",
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
user_id="user_123",
app_id="app_123"
)
# Add user input to memory
user_input = "I need help with my account"
await external_memory.add(MemoryContent(content=user_input, mime_type=MemoryMimeType.TEXT))
# Add assistant text messages to memory
if hasattr(result, "messages"):
for msg in result.messages[-1]:
if getattr(msg, "type", None) == "TextMessage":
await external_memory.add(
MemoryContent(
content=getattr(msg, "content", ""),
mime_type=MemoryMimeType.TEXT
)
)
  1. Memory Provider Setup - Always configure memory providers in FloTorch Console before using them in code
  2. User/App Isolation - Use appropriate user_id and app_id values to isolate memory per user and application
  3. Content Management - Properly extract and store content from AutoGen messages with appropriate MIME types
  4. Error Handling - Implement proper error handling for memory operations in production environments
  5. Memory Cleanup - Consider implementing memory cleanup strategies for long-running applications