AppSearchMemoryService

A persistent MemoryService backed by AndroidX AppSearch in the consumer app's private storage.

Ingested events and explicit memories survive process death and reboot, never leave the device, and are retrieved by AppSearch's native full-text relevance ranking. Use this in place of com.google.adk.kt.memory.InMemoryMemoryService when constructing a com.google.adk.kt.runners.Runner in an Android consumer app:

val memoryService = AppSearchMemoryService.fromContext(applicationContext)

Memory is scoped by (appName, userId): a search never returns another user's memory. All three write paths are supported and each event / explicit memory becomes its own retrievable document.

This class holds all behavior and delegates storage to a MemoryIndex so it can be unit-tested on the host JVM; fromContext wires it to the on-device LocalStorageMemoryIndex.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun addEventsToMemory(appName: String, userId: String, events: List<Event>, sessionId: String? = null, customMetadata: Map<String, Any?>? = null)

Adds an explicit list of events to the memory service.

Link copied to clipboard
open suspend override fun addMemory(appName: String, userId: String, memories: List<MemoryEntry>, customMetadata: Map<String, Any?>? = null)

Adds explicit memory items directly to the memory service.

Link copied to clipboard
open suspend override fun addSessionToMemory(session: Session)

Adds a session to the memory service.

Link copied to clipboard
open override fun close()

Releases the underlying index resources. Primarily useful for tests.

Link copied to clipboard
open suspend override fun searchMemory(appName: String, userId: String, query: String): SearchMemoryResponse

Searches for sessions that match the query asynchronously.