ADK Plugin: Agent
The FlotorchADKAgent serves as the primary component for integrating FloTorch-managed agent configurations with Google ADK. 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 FlotorchADKAgent, ensure you have completed the general prerequisites outlined in the ADK Plugin Overview, including installation and environment configuration.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”Configure your agent using the following parameters:
FlotorchADKAgent( agent_name: str, # Agent name from FloTorch Console (required) enable_memory: bool = False, # Enable memory functionality custom_tools: list = None, # List of custom user-defined tools base_url: str = None, # FloTorch Gateway URL api_key: str = None, # FloTorch API key tracer_config: dict = None # Optional tracing configuration)Parameter Details:
agent_name- Must match an existing agent name in your FloTorch Consoleenable_memory- WhenTrue, automatically includes ADK memory tools (preload_memory) for the agentcustom_tools- List of custom ADK tools to add to the agent’s capabilitiesbase_url- FloTorch Gateway endpoint (defaults to environment variableFLOTORCH_BASE_URL)api_key- Authentication key (defaults to environment variableFLOTORCH_API_KEY)tracer_config- Optional dictionary for configuring distributed tracing and observability
Note: If
enable_memory=True, you must initializeFlotorchMemoryServiceand pass it to the ADKRunnervia thememory_serviceparameter.
Tracing Configuration
Section titled “Tracing Configuration”The tracer_config parameter enables distributed tracing for your agent, allowing you to monitor and debug agent execution across your system. This is particularly useful for production deployments and complex multi-agent workflows.
Tracer Configuration Parameters:
tracer_config = { "enabled": True, # Required: Enable or disable tracing "endpoint": "<your_observability_endpoint>", # Required: OTLP HTTP endpoint for trace export "sampling_rate": 1.0, # Required: Sampling rate (0.0 to 1.0), where 1.0 captures all traces "protocol": "https", # Optional: Protocol for the exporter ("https" for HTTP exporter) "service_name": "flotorch-adk-plugin", # Optional: Service name to distinguish plugin traces from gateway "service_version": "1.0.0", # Optional: Service version identifier # "enable_plugins_llm_tracing": True, # Optional: Enable LLM tracing in plugins}Required Fields:
enabled(bool) - Set toTrueto enable tracing,Falseto disableendpoint(str) - OTLP HTTP endpoint URL where traces will be exported (e.g.,"<your_observability_endpoint>")sampling_rate(float) - Trace sampling rate between 0.0 and 1.0. Use1.0to capture all traces, or lower values (e.g.,0.1) to reduce overhead in high-traffic scenarios
Optional Fields:
protocol(str) - Protocol for the exporter. Use"https"for HTTP exporter (default)service_name(str) - Service identifier to distinguish plugin traces from gateway traces in observability dashboardsservice_version(str) - Version identifier for your serviceenable_plugins_llm_tracing(bool) - Enable detailed LLM tracing within plugins
Example Tracing Configuration:
from flotorch.adk.agent import FlotorchADKAgent
# Configure tracing for production observabilitytracer_config = { "enabled": True, "endpoint": "<your_observability_endpoint>", "protocol": "https", "service_name": "flotorch-adk-plugin", "service_version": "1.0.0", "sampling_rate": 1.0,}
agent_manager = FlotorchADKAgent( agent_name="my-agent", tracer_config=tracer_config, base_url="https://gateway.flotorch.cloud", api_key="your_api_key")Note: Tracing is disabled by default. You must explicitly provide
tracer_configwithenabled=Trueto activate tracing functionality.
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 description
- System instructions and prompts
- 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
- Memory Tools - Automatically includes
preload_memorywhenenable_memory=True - Custom Tools - Add your own ADK tools via the
custom_toolsparameter - Tool Management - Handles authentication and connection automatically
- Multiple Formats - Supports various tool transport types (HTTP_STREAMABLE, HTTP_SSE)
Logging Configuration
Section titled “Logging Configuration”FloTorch ADK 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.adk.agent import FlotorchADKAgentfrom google.adk import Runner
# Initialize the agent manageragent_manager = FlotorchADKAgent( agent_name="my-agent", # Must exist in FloTorch Console base_url="https://gateway.flotorch.cloud", api_key="your_api_key" # Note: Agent description and instructions are configured # in the FloTorch Console during agent creation)
# Get the configured agentagent = agent_manager.get_agent()
# Run the agent using ADK Runnerrunner = Runner(agent=agent)
# Launch the agent with ADK web interface# Run: adk webAgent with Tracing Enabled
Section titled “Agent with Tracing Enabled”from flotorch.adk.agent import FlotorchADKAgentfrom google.adk import Runner
# Configure tracing for observabilitytracer_config = { "enabled": True, "endpoint": "<your_observability_endpoint>", "sampling_rate": 1.0, "service_name": "flotorch-adk-plugin",}
# Initialize the agent manager with tracingagent_manager = FlotorchADKAgent( agent_name="my-agent", tracer_config=tracer_config, base_url="https://gateway.flotorch.cloud", api_key="your_api_key")
# Get the configured agentagent = agent_manager.get_agent()
# Run the agent using ADK Runnerrunner = Runner(agent=agent)Agent with Custom Tools
Section titled “Agent with Custom Tools”from flotorch.adk.agent import FlotorchADKAgentfrom google.adk import Runnerfrom google.adk.tools import FunctionTool
# Define a custom weather tool using ADK's tool creationdef 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 """ # In a real implementation, this would call a weather API # For demonstration, we'll return a mock response return f"The weather in {location} is sunny with a temperature of 72°F (22°C)."
tools = [FunctionTool(get_weather)]# Initialize agent with custom weather toolagent_manager = FlotorchADKAgent( agent_name="weather-agent", custom_tools=tools, # Add the custom weather tool base_url="https://gateway.flotorch.cloud", api_key="your_api_key")
# Get the configured agentagent = agent_manager.get_agent()
# Run the agentrunner = Runner(agent=agent)
# Launch the agent with ADK web interface# Run: adk webBest 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
- Memory Tools - Enable memory only when agents need to access persistent memory to avoid unnecessary overhead
- Custom Tools - Define custom tools with clear descriptions and proper error handling for robust agent behavior
- Tracing - Enable tracing in production environments for observability and debugging. Use appropriate sampling rates to balance visibility with performance
- 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