You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a specific problem?
ADK ships three memory services, and none of them offers persistent, semantic
memory on infrastructure a user controls:
InMemoryMemoryService ranks by keyword overlap and its own docstring says it
is for "prototyping purpose only" — it loses everything on restart.
VertexAiMemoryBankService and VertexAiRagMemoryService provide semantic
memory but require Google Cloud.
So teams that need semantic long-term memory but run on-premise, in air-gapped
environments, or under data-residency constraints (e.g. EU/GDPR) have no
built-in option — the exact gap raised in #6254. The pending SQLite memory
service (#4116) adds persistence but, as noted in its own review, gives
"exact-match queries" rather than semantic retrieval. Postgres with pgvector
is the natural way to close the semantic half of that gap on self-hosted
infrastructure.
Describe the Solution You'd Like
A new PgVectorMemoryService (under google.adk.integrations.pgvector) that
implements BaseMemoryService and stores event embeddings in a PostgreSQL table
with the pgvector extension:
add_session_to_memory / add_events_to_memory embed each event's text and
upsert it (idempotent per event) into the table, scoped by (app_name, user_id).
search_memory embeds the query and returns the nearest memories by cosine
distance via a pgvector HNSW index.
Embeddings are produced through the existing google-genai client by default,
and an injectable embedder callable makes the service provider-agnostic.
Ships as an optional extra: pip install "google-adk[pgvector]".
It follows the existing integrations/redis pattern (config object + injectable
client), so the store runs entirely on a database the user owns.
Impact on your work
Lets ADK agents keep persistent, semantically searchable memory without adopting
a managed cloud memory service — important for on-prem, air-gapped, and
data-residency-constrained deployments, and for local development against a real
(not in-memory) store.
Willingness to contribute
Yes — I have a working implementation with unit tests and am ready to open a PR.
I'd like to take this one: could a maintainer please assign it to me? I'll open
the PR once there's a maintainer go-ahead on the approach.
🟡 Recommended Information
Describe Alternatives You've Considered
InMemoryMemoryService — not persistent, keyword-only.
Vertex AI memory services — require GCP; unusable for the deployments
above.
A generic SQLAlchemy memory service — would still need a vector type and
index; targeting pgvector directly keeps the HNSW index and cosine operator
first-class.
Proposed API / Implementation
fromgoogle.adk.integrations.pgvectorimportPgVectorMemoryServicefromgoogle.adk.integrations.pgvectorimportPgVectorMemoryServiceConfigmemory_service=PgVectorMemoryService(
PgVectorMemoryServiceConfig(
dsn="postgresql://user:password@localhost:5432/adk",
embedding_model="gemini-embedding-001",
embedding_dimension=768,
)
)
awaitmemory_service.add_session_to_memory(session)
response=awaitmemory_service.search_memory(
app_name="my_app", user_id="user1", query="what did we decide about billing?"
)
Implementation notes:
integrations/pgvector/ package: PgVectorMemoryServiceConfig, PgVectorMemoryService, and a README.
One table adk_memory_entries (configurable) with a vector(dim) column, a (app_name, user_id) index, and an HNSW index using vector_cosine_ops;
created on first use.
psycopg (v3) async + psycopg_pool.AsyncConnectionPool; the connection pool
and the embedder are both injectable, which keeps the service unit-testable
without a live database.
New optional extra pgvector (psycopg[binary], psycopg-pool, pgvector).
Additional Context
The design mirrors the existing integrations/redis session service and the google-genai embedding usage already in tools/spanner and integrations/mongodb. Happy to align the storage schema with the direction of #4116 if the maintainers prefer a shared table layout.
🔴 Required Information
Is your feature request related to a specific problem?
ADK ships three memory services, and none of them offers persistent, semantic
memory on infrastructure a user controls:
InMemoryMemoryServiceranks by keyword overlap and its own docstring says itis for "prototyping purpose only" — it loses everything on restart.
VertexAiMemoryBankServiceandVertexAiRagMemoryServiceprovide semanticmemory but require Google Cloud.
So teams that need semantic long-term memory but run on-premise, in air-gapped
environments, or under data-residency constraints (e.g. EU/GDPR) have no
built-in option — the exact gap raised in #6254. The pending SQLite memory
service (#4116) adds persistence but, as noted in its own review, gives
"exact-match queries" rather than semantic retrieval. Postgres with
pgvectoris the natural way to close the semantic half of that gap on self-hosted
infrastructure.
Describe the Solution You'd Like
A new
PgVectorMemoryService(undergoogle.adk.integrations.pgvector) thatimplements
BaseMemoryServiceand stores event embeddings in a PostgreSQL tablewith the
pgvectorextension:add_session_to_memory/add_events_to_memoryembed each event's text andupsert it (idempotent per event) into the table, scoped by
(app_name, user_id).search_memoryembeds the query and returns the nearest memories by cosinedistance via a pgvector HNSW index.
google-genaiclient by default,and an injectable
embeddercallable makes the service provider-agnostic.pip install "google-adk[pgvector]".It follows the existing
integrations/redispattern (config object + injectableclient), so the store runs entirely on a database the user owns.
Impact on your work
Lets ADK agents keep persistent, semantically searchable memory without adopting
a managed cloud memory service — important for on-prem, air-gapped, and
data-residency-constrained deployments, and for local development against a real
(not in-memory) store.
Willingness to contribute
Yes — I have a working implementation with unit tests and am ready to open a PR.
I'd like to take this one: could a maintainer please assign it to me? I'll open
the PR once there's a maintainer go-ahead on the approach.
🟡 Recommended Information
Describe Alternatives You've Considered
InMemoryMemoryService— not persistent, keyword-only.above.
rather than replaces a vector backend.
index; targeting pgvector directly keeps the HNSW index and cosine operator
first-class.
Proposed API / Implementation
Implementation notes:
integrations/pgvector/package:PgVectorMemoryServiceConfig,PgVectorMemoryService, and a README.adk_memory_entries(configurable) with avector(dim)column, a(app_name, user_id)index, and an HNSW index usingvector_cosine_ops;created on first use.
psycopg(v3) async +psycopg_pool.AsyncConnectionPool; the connection pooland the embedder are both injectable, which keeps the service unit-testable
without a live database.
pgvector(psycopg[binary],psycopg-pool,pgvector).Additional Context
The design mirrors the existing
integrations/redissession service and thegoogle-genaiembedding usage already intools/spannerandintegrations/mongodb. Happy to align the storage schema with the direction of#4116 if the maintainers prefer a shared table layout.