A2aSessionManager

class A2aSessionManager(client: A2aGrpcClient, tenant: String)

Creates and tracks A2aSessions. Hold one per app (alongside the OtvSdkClient) so sessions outlive Activities. Sessions are in memory only and do not survive process death. Several sessions may be active at once; each has its own conversation context.

Constructors

Link copied to clipboard
constructor(client: A2aGrpcClient, tenant: String)

Functions

Link copied to clipboard
fun getSession(contextId: String): A2aSession?

Finds a managed session by its current context id.

Link copied to clipboard
fun resumeSession(contextId: String, config: SessionConfig = SessionConfig()): A2aSession

Continues the conversation with the given server-issued contextId. If a live session already uses that id it is returned, so one conversation never has two sessions. Otherwise a new session starts with that id; if the server no longer knows it (contexts are kept about 30 minutes) it starts a new conversation and the session's A2aSession.contextId changes. Ids are not persisted by the SDK.

Link copied to clipboard
fun startSession(config: SessionConfig = SessionConfig()): A2aSession

Starts a session. It has no id yet: the server issues the context id with the first response, after which the session can also be found with getSession.

Link copied to clipboard
suspend fun stopAll()

Stops every active session.

Link copied to clipboard
suspend fun stopSession(session: A2aSession): Boolean

Stops and forgets the session. Returns false if it is not managed here.

suspend fun stopSession(contextId: String): Boolean

Stops the session with the given server-issued context id. Returns false if unknown.