Skip to content

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.

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

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 Console
  • enable_memory - When True, automatically includes ADK memory tools (preload_memory) for the agent
  • custom_tools - List of custom ADK tools to add to the agent’s capabilities
  • base_url - FloTorch Gateway endpoint (defaults to environment variable FLOTORCH_BASE_URL)
  • api_key - Authentication key (defaults to environment variable FLOTORCH_API_KEY)
  • tracer_config - Optional dictionary for configuring distributed tracing and observability

Note: If enable_memory=True, you must initialize FlotorchMemoryService and pass it to the ADK Runner via the memory_service parameter.

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 to True to enable tracing, False to disable
  • endpoint (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. Use 1.0 to 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 dashboards
  • service_version (str) - Version identifier for your service
  • enable_plugins_llm_tracing (bool) - Enable detailed LLM tracing within plugins

Example Tracing Configuration:

from flotorch.adk.agent import FlotorchADKAgent
# Configure tracing for production observability
tracer_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_config with enabled=True to activate tracing functionality.

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

Supports automatic configuration updates based on:

  • syncEnabled - Enables automatic configuration reloading
  • syncInterval - 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.

Automatically integrates tools configured in FloTorch Console:

  • MCP Tools - Loaded directly from agent configuration
  • Memory Tools - Automatically includes preload_memory when enable_memory=True
  • Custom Tools - Add your own ADK tools via the custom_tools parameter
  • Tool Management - Handles authentication and connection automatically
  • Multiple Formats - Supports various tool transport types (HTTP_STREAMABLE, HTTP_SSE)

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:

Terminal window
# Enable debug logging to console
export FLOTORCH_LOG_DEBUG=true
export 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.

from flotorch.adk.agent import FlotorchADKAgent
from google.adk import Runner
# Initialize the agent manager
agent_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 agent
agent = agent_manager.get_agent()
# Run the agent using ADK Runner
runner = Runner(agent=agent)
# Launch the agent with ADK web interface
# Run: adk web
from flotorch.adk.agent import FlotorchADKAgent
from google.adk import Runner
# Configure tracing for observability
tracer_config = {
"enabled": True,
"endpoint": "<your_observability_endpoint>",
"sampling_rate": 1.0,
"service_name": "flotorch-adk-plugin",
}
# Initialize the agent manager with tracing
agent_manager = FlotorchADKAgent(
agent_name="my-agent",
tracer_config=tracer_config,
base_url="https://gateway.flotorch.cloud",
api_key="your_api_key"
)
# Get the configured agent
agent = agent_manager.get_agent()
# Run the agent using ADK Runner
runner = Runner(agent=agent)
from flotorch.adk.agent import FlotorchADKAgent
from google.adk import Runner
from google.adk.tools import FunctionTool
# Define a custom weather tool using ADK's tool creation
def 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 tool
agent_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 agent
agent = agent_manager.get_agent()
# Run the agent
runner = Runner(agent=agent)
# Launch the agent with ADK web interface
# Run: adk web
  1. Configuration Management - Define agent configurations in FloTorch Console rather than in code
  2. Environment Variables - Use environment variables for credentials to avoid hardcoding sensitive information
  3. Configuration Sync - Enable synchronization in the Console to receive updates without redeployment
  4. Memory Tools - Enable memory only when agents need to access persistent memory to avoid unnecessary overhead
  5. Custom Tools - Define custom tools with clear descriptions and proper error handling for robust agent behavior
  6. Tracing - Enable tracing in production environments for observability and debugging. Use appropriate sampling rates to balance visibility with performance
  7. Logging - Configure logging based on your environment: use console logging for development and file logging for production. See SDK Logging Configuration for details