RoomSessionService
A persistent SessionService backed by a Room/SQLite database in the consumer app's private storage.
Sessions, events, and app/user state survive process death and device reboot. Use this in place of InMemorySessionService when constructing a com.google.adk.kt.runners.Runner in an Android consumer app.
Default usage — one instance per Application:
val sessionService = RoomSessionService.fromContext(applicationContext)Pass a distinct databaseName to give an agent its own SQLite file (e.g. when two agents in the same app should not see each other's sessions even within the same appName):
val agentASessions = RoomSessionService.fromContext(context, "agent_a.db")
val agentBSessions = RoomSessionService.fromContext(context, "agent_b.db")Dispatching is handled by Room — suspend fun DAO calls run on Room's internal transaction executor, so this class does not need to wrap calls in withContext.
Functions
Appends an event to an in-memory session object and updates the session's state based on the event's state delta, if applicable.
Closes the underlying Room database, releasing the file handle. Primarily useful for tests that construct and destroy services repeatedly. In a normal app the database stays open for the process lifetime — Android does not require explicit close.
Closes a session.
Creates a new session with the specified parameters.
Deletes a specific session.
Retrieves a specific session, optionally filtering the events included.
Lists the events within a specific session.
Lists sessions associated with a specific application and user.