postgresql backend stores sessions in a PostgreSQL database. Multiple agent instances can connect to the same database for shared, distributed persistence.
When to use
- Production, multi-instance, or distributed deployments;
- Teams already using PostgreSQL as shared storage.
Prerequisites
Theveadk-python installation includes the required database drivers. Before running the example, create the database and account, grant permissions to create and read/write session tables, and make the database reachable. VeADK does not provision the database service or database itself
Provide connection settings through environment variables and inject the password from your deployment secret configuration
DATABASE_POSTGRESQL_PASSWORD. These settings work with reachable self-managed, Volcengine, or BytePlus database instances; they do not automatically select a cloud provider or region
Usage
Provide connection details viaconfig.yaml (or the matching environment variables) — never hard-code the password.
chat_01, confirming that the session was created and read back. This example does not call a model. For conversations, pass the same stm to Runner(short_term_memory=stm, agent=agent) and keep the app, user, and session identifiers consistent
To forward SQLAlchemy driver args such as connection pooling, use db_kwargs:
PostgreSqlConfig directly through backend_configs to override the environment variables:
Parameters
ShortTermMemory constructor parameters (postgresql)
PostgreSqlConfig fields and environment variables
ThePostgreSqlConfig config class uses the env prefix DATABASE_POSTGRESQL_.
config.yaml
VeADK selects a PostgreSQL driver compatible with the installed Google ADK version and automatically encodes special characters in usernames and passwords. You can provision PostgreSQL on Volcengine.
schema when several VeADK deployments share a database but must keep separate session tables. Schema names may contain letters, digits, and underscores and cannot start with a digit.