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_PREFIXkeys - User State - In-memory user-level state with
State.USER_PREFIXkeys
Prerequisites
Section titled “Prerequisites”Before using FlotorchADKSession, 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 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)
Features
Section titled “Features”Persistent Session Storage
Section titled “Persistent Session Storage”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
State Management
Section titled “State Management”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_PREFIXkey prefix - Suitable for application-wide settings and configurations
User State:
- Managed in-memory for user-specific data
- Uses
State.USER_PREFIXkey prefix - Ideal for user preferences and temporary data
Event Handling
Section titled “Event Handling”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
Usage Example
Section titled “Usage Example”Basic Session Setup
Section titled “Basic Session Setup”from flotorch.adk.sessions import FlotorchADKSessionfrom google.adk import Runner
# Initialize session servicesession_service = FlotorchADKSession( api_key="your_api_key", base_url="https://gateway.flotorch.cloud")
# Use with Runnerrunner = Runner( agent=your_agent, session_service=session_service)Best Practices
Section titled “Best Practices”- Environment Variables - Use environment variables for credentials to enhance security
- Session Management - Implement proper session lifecycle management
- Error Handling - Implement robust error handling for network and storage operations
Next Steps
Section titled “Next Steps”- Agent Configuration - Learn how to configure agents with session management
- Memory Integration - Add memory capabilities alongside sessions
- LLM Configuration - Configure language models for your session-enabled agents