AutoGen Plugin: Agent
The FlotorchAutogenAgent serves as the primary component for integrating FloTorch-managed agent configurations with Microsoft AutoGen (agentchat). It enables developers to define agent configurations centrally in the FloTorch Console and instantiate them with minimal code, eliminating the need for complex in-code configuration management.
Prerequisites
Section titled “Prerequisites”Before using FlotorchAutogenAgent, ensure you have completed the general prerequisites outlined in the AutoGen Plugin Overview, including installation and environment configuration.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”Configure your agent using the following parameters:
FlotorchAutogenAgent( agent_name: str, # Agent name from FloTorch Console (required) api_key: str, # FloTorch API key (required) base_url: str, # FloTorch Gateway URL (required) custom_tools: list = None, # List of custom user-defined tools memory: list = None, # List of memory services (e.g., [FlotorchAutogenMemory]) model_context: object = None # Short-term context (e.g., FlotorchAutogenSession))Parameter Details:
agent_name- Must match an existing agent name in your FloTorch Consoleapi_key- Authentication key for accessing FloTorch Gateway (can be set via environment variableFLOTORCH_API_KEY)base_url- FloTorch Gateway endpoint URL (can be set via environment variableFLOTORCH_BASE_URL)custom_tools- List of custom AutoGen tools to add to the agent’s capabilitiesmemory- List of memory services for long-term persistent storage (e.g.,[FlotorchAutogenMemory])model_context- Short-term model context for conversation history (e.g.,FlotorchAutogenSession)
Note: The
memoryparameter expects a list of memory storage services, whilemodel_contextprovides short-term conversational context.
Features
Section titled “Features”Automatic Configuration Loading
Section titled “Automatic Configuration Loading”The agent automatically loads comprehensive configuration from FloTorch Console, including:
- Agent name and system prompt
- LLM model configuration
- Input/output schemas
- MCP tools configuration
- Synchronization settings
Configuration Synchronization
Section titled “Configuration Synchronization”Supports automatic configuration updates based on:
syncEnabled- Enables automatic configuration reloadingsyncInterval- Defines the synchronization interval in seconds
This ensures your agent stays up-to-date with changes made in the FloTorch Console without requiring code redeployment.
Tool Integration
Section titled “Tool Integration”Automatically integrates tools configured in FloTorch Console:
- MCP Tools - Loaded directly from agent configuration
- Custom Tools - Add your own AutoGen tools via the
custom_toolsparameter - Tool Management - Handles authentication and connection automatically
- AutoGen Compatibility - Seamlessly integrates with AutoGen’s tool framework
Logging Configuration
Section titled “Logging Configuration”FloTorch AutoGen Plugin supports configurable logging to help you monitor and debug your agents. For comprehensive logging configuration details, including environment variables and programmatic setup, refer to the SDK Logging Configuration documentation.
Quick Setup:
# Enable debug logging to consoleexport FLOTORCH_LOG_DEBUG=trueexport FLOTORCH_LOG_PROVIDER="console"Or configure programmatically:
from flotorch.sdk.logger.global_logger import configure_logger
configure_logger(debug=True, log_provider="console")For detailed logging configuration options, see the SDK Logging Configuration guide.
Usage Example
Section titled “Usage Example”Basic Agent Setup
Section titled “Basic Agent Setup”from flotorch.autogen.agent import FlotorchAutogenAgent
# Initialize the agent manageragent_manager = FlotorchAutogenAgent( agent_name="my-agent", # Must exist in FloTorch Console base_url="https://gateway.flotorch.cloud", api_key="your_api_key" # Note: Agent system prompt is configured # in the FloTorch Console during agent creation)
# Get the configured agentagent = agent_manager.get_agent()Agent with Custom Tools
Section titled “Agent with Custom Tools”from flotorch.autogen.agent import FlotorchAutogenAgent
# Define a custom weather tooldef get_weather(location: str) -> str: """ Get the current weather for a specific location. Args: location: The city or location name to get weather for Returns: A string describing the current weather conditions """ return f"The weather in {location} is sunny with a temperature of 72°F (22°C)."
# Initialize agent with custom weather toolagent_manager = FlotorchAutogenAgent( agent_name="weather-agent", custom_tools=[get_weather], # Add the custom weather tool base_url="https://gateway.flotorch.cloud", api_key="your_api_key")
# Get the configured agentagent = agent_manager.get_agent()Best Practices
Section titled “Best Practices”- Configuration Management - Define agent configurations in FloTorch Console rather than in code
- Environment Variables - Use environment variables for credentials to avoid hardcoding sensitive information
- Configuration Sync - Enable synchronization in the Console to receive updates without redeployment
- Custom Tools - Define custom tools with clear descriptions and proper error handling for robust agent behavior
- Logging - Configure logging based on your environment: use console logging for development and file logging for production. See SDK Logging Configuration for details
Next Steps
Section titled “Next Steps”- LLM Configuration - Configure language models for your agent
- Memory Integration - Add persistent memory capabilities
- Session Management - Implement session persistence