AgentSession

interface AgentSession : AutoCloseable


A scoped session handle representing an ongoing multi-turn conversational thread with an AgentRunner.

Encapsulates the sessionId, turn execution via runAsync, and session history lifecycle. Closing the session evicts its in-memory dialogue history.

Summary

Public functions

Unit

Closes this session handle and asynchronously evicts its in-memory dialogue history.

suspend Unit

Deletes this session's in-memory conversation history and cancels active turns.

Flow<AgentEvent>
runAsync(content: Content)

Executes an interaction turn within this session using multimodal Content.

Public properties

String

The unique identifier tracking conversation history in memory for this session.

Public functions

close

fun close(): Unit

Closes this session handle and asynchronously evicts its in-memory dialogue history.

Dialogue history cleanup is dispatched asynchronously in the background. If you require guaranteed synchronous eviction before immediately recreating a session with the same sessionId, invoke delete instead.

delete

suspend fun delete(): Unit

Deletes this session's in-memory conversation history and cancels active turns.

This suspending call synchronously completes in-memory and ADK history deletion before returning. Use this when you require guaranteed immediate history eviction before recreating a session with the same sessionId.

runAsync

fun runAsync(content: Content): Flow<AgentEvent>

Executes an interaction turn within this session using multimodal Content.

Parameters
content: Content

The multimodal content (text, images, etc.).

Returns
Flow<AgentEvent>

A cold Flow of AgentEvents emitted during execution.

Public properties

sessionId

val sessionId: String

The unique identifier tracking conversation history in memory for this session.