Skip to content

ADK Plugin: Session

FlotorchADKSession provides an ADK-compatible session service that uses FloTorch’s Session API for persistent session management while maintaining in-memory state for app and user state.


from flotorch.adk.sessions import FlotorchADKSession
API_KEY = "<your_api_key>"
BASE_URL = "https://gateway.flotorch.cloud"

FlotorchADKSession(
api_key: str,
base_url: str,
)

Creates an ADK-compatible session service backed by FloTorch Session API.

async def create_session(
self,
*,
app_name: str,
user_id: str,
state: dict[str, Any] | None = None,
session_id: str | None = None,
) -> Session

Creates a new session with optional initial state.

async def get_session(
self,
*,
app_name: str,
user_id: str,
session_id: str,
config: GetSessionConfig | None = None,
) -> Session | None

Retrieves a session with optional event filtering.

list_sessions(…) -> ListSessionsResponse

Section titled “list_sessions(…) -> ListSessionsResponse”
async def list_sessions(
self,
*,
app_name: str,
user_id: str
) -> ListSessionsResponse

Lists sessions for a user/app combination.

async def delete_session(
self,
*,
app_name: str,
user_id: str,
session_id: str
) -> None

Deletes a session.

async def append_event(self, session: Session, event: Event) -> Event

Appends an event to a session with state delta handling.


  • Session State: Stored in FloTorch Session
  • App State: Kept in memory with State.APP_PREFIX keys
  • User State: Kept in memory with State.USER_PREFIX keys
  • ADK → FloTorch: Converts ADK events to FloTorch format for storage
  • Flotorch → ADK: Converts stored events back to ADK format
  • Tool Call Support: Handles tool calls and function responses

Automatically processes state deltas in events to update app and user state.


from google.adk.runner import Runner
# Create session service
session_service = FlotorchADKSession(
api_key=API_KEY,
base_url=BASE_URL
)
# Use with Runner
runner = Runner(
agent=agent,
session_service=session_service
)
# Sessions are automatically managed

  • Session state is persisted in FloTorch, app/user state in memory
  • Event conversion handles complex ADK content structures
  • State deltas are processed automatically on event append
  • Sync methods are deprecated, use async versions