VertexAiMemoryBankService

A MemoryService backed by Vertex AI Agent Engine Memory Bank.

This is a Kotlin port of the Python ADK VertexAiMemoryBankService. Memories are scoped by {app_name, user_id}; addSessionToMemory and addEventsToMemory send event content for server-side memory generation, addMemory writes explicit memories (directly, or via generation when consolidation is requested), and searchMemory retrieves memories by semantic similarity.

It follows the existing Vertex service ports: a thin VertexAiMemoryBankClient over a shared GoogleApiClient handles the REST calls, and @Serializable wire DTOs live in the dto sub-package.

Constructors

Link copied to clipboard
constructor(project: String, location: String, agentEngineId: String, credentials: GoogleCredentials = GoogleApiClient.defaultCredentials(), httpClient: HttpClient = HttpClient(Java))

Creates a service for Agent Engine agentEngineId under project and location.

Types

Link copied to clipboard
class Builder

Fluent builder for VertexAiMemoryBankService, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

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 events for memory generation. Uses memories:ingestEvents by default; if customMetadata carries a key only memories:generate accepts (e.g. ttl, metadata, disable_consolidation), the generate path is used. See GENERATE_ONLY_KEYS for the keys.

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

Writes memories as explicit facts, or consolidates them server-side via generate when enable_consolidation is set in customMetadata (the generate config keys in customMetadata then apply). Only each entry's text is persisted; per-entry author, timestamp, and customMetadata are not written (Python 2.0 maps them to revision labels and merged metadata).

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

Adds a session to the memory service.

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

Searches for sessions that match the query asynchronously.