Skip to content

ADK Plugin: Session

The FlotorchADKSession provides comprehensive session management for ADK 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 Google ADK’s agent framework.

State Management Layers:

  • Session State - Persisted in FloTorch Gateway for conversation continuity
  • App State - In-memory application-level state with State.APP_PREFIX keys
  • User State - In-memory user-level state with State.USER_PREFIX keys

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

Configure your session service with the following parameters:

FlotorchADKSession(
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 ADK and FloTorch formats

Implements a three-tier state management system:

Session State:

  • Persisted in FloTorch Gateway
  • Maintains conversation continuity across sessions
  • Automatically synchronized with the backend

App State:

  • Managed in-memory for application-level data
  • Uses State.APP_PREFIX key prefix
  • Suitable for application-wide settings and configurations

User State:

  • Managed in-memory for user-specific data
  • Uses State.USER_PREFIX key prefix
  • Ideal for user preferences and temporary data

Automatically manages event processing and conversion:

  • Event Conversion - Converts between ADK and FloTorch event formats
  • Tool Call Management - Handles tool call execution and responses
  • Function Responses - Processes function call results
  • State Deltas - Applies state changes incrementally
from flotorch.adk.sessions import FlotorchADKSession
from google.adk import Runner
# Initialize session service
session_service = FlotorchADKSession(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud"
)
# Use with Runner
runner = Runner(
agent=your_agent,
session_service=session_service
)
  1. Environment Variables - Use environment variables for credentials to enhance security
  2. Session Management - Implement proper session lifecycle management
  3. Error Handling - Implement robust error handling for network and storage operations