Skip to content

AutoGen Plugin: Session

The FlotorchAutogenSession provides comprehensive session management for AutoGen agents, enabling persistent storage of conversation history and session data through FloTorch Gateway. It seamlessly handles state management, event conversion, and persistent storage while maintaining compatibility with Microsoft AutoGen’s agent framework. It serves as short-term model context for conversational context.

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

Configure your session service with the following parameters:

FlotorchAutogenSession(
api_key: str, # FloTorch API key for authentication (required)
base_url: str # FloTorch Gateway endpoint URL (required)
)

Parameter Details:

  • api_key - Authentication key for accessing FloTorch Gateway (can be set via environment variable)
  • base_url - The FloTorch Gateway endpoint URL (can be set via environment variable)

Provides comprehensive session persistence capabilities:

  • Gateway Storage - Stores session data persistently in FloTorch Gateway
  • Event History - Preserves complete event history across service restarts
  • State Synchronization - Automatically synchronizes state management
  • Format Conversion - Seamlessly converts events between AutoGen and FloTorch formats

Serves as AutoGen’s model context for short-term conversational context:

  • Conversation History - Maintains conversation history for the current session
  • Context Management - Provides context for model interactions
  • Automatic Updates - Automatically updates context as conversations progress

Automatically manages event processing and conversion:

  • Event Conversion - Converts between AutoGen and FloTorch event formats
  • Message Handling - Handles text messages and tool responses
  • State Management - Manages session state throughout the conversation
  • Persistence - Ensures events are persisted to FloTorch Gateway
from flotorch.autogen.agent import FlotorchAutogenAgent
from flotorch.autogen.sessions import FlotorchAutogenSession
# Initialize session service
session_memory = FlotorchAutogenSession(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud"
)
# Use with agent as model context
agent_manager = FlotorchAutogenAgent(
agent_name="customer-support",
model_context=session_memory, # Short-term context
base_url="https://gateway.flotorch.cloud",
api_key="your_api_key"
)
agent = agent_manager.get_agent()
  1. Environment Variables - Use environment variables for credentials to enhance security
  2. Session Management - Implement proper session lifecycle management for long-running applications
  3. Error Handling - Implement robust error handling for network and storage operations
  4. Session Cleanup - Consider implementing session cleanup strategies for production environments