Skip to content

AdkApp - Session Service Builder with AlloyDB - Connection Error #3304

@julienvincendeau-rc

Description

@julienvincendeau-rc

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
I want to use DatabaseSessionService with my AlloyDB.
When I want to access on it, no error.
When I want to use with AdkApp, I've got an error.

To Reproduce
Here my code :

...

import logging
import sqlalchemy
import pg8000
from google.adk.sessions import DatabaseSessionService

....
# Initialize Vertex AI SDK
vertexai.init(
    project=GOOGLE_CLOUD_PROJECT,
    location=GOOGLE_CLOUD_LOCATION,
    staging_bucket=STAGING_BUCKET,
)
session_service = DatabaseSessionService(db_url=f"postgresql+pg8000://{db_user}:{db_pass}@{alloydb_instance_uri}/{db_name}", echo=True)


logger.info("deploying app...")
app = AdkApp(
    agent=root_agent,
    session_service_builder= lambda: DatabaseSessionService(
        db_url=f"postgresql+pg8000://{db_user}:{db_pass}@{alloydb_instance_uri}/{db_name}"
    ),
    enable_tracing=True,
)

Expected behavior
on this parts

session_service = DatabaseSessionService(db_url=f"postgresql+pg8000://{db_user}:{db_pass}@{alloydb_instance_uri}/{db_name}", echo=True)

I've got a sucess output

DEBUG:tzlocal:/etc/localtime found
DEBUG:tzlocal:2 found:
 {'/etc/timezone': 'Etc/UTC', '/etc/localtime is a symlink to': 'Etc/UTC'}
INFO:google_adk.google.adk.sessions.database_session_service:Local timezone: Etc/UTC
2025-10-27 18:05:37,115 INFO sqlalchemy.engine.Engine select pg_catalog.version()
INFO:sqlalchemy.engine.Engine:select pg_catalog.version()
2025-10-27 18:05:37,115 INFO sqlalchemy.engine.Engine [raw sql] ()
INFO:sqlalchemy.engine.Engine:[raw sql] ()
2025-10-27 18:05:37,371 INFO sqlalchemy.engine.Engine select current_schema()
INFO:sqlalchemy.engine.Engine:select current_schema()
2025-10-27 18:05:37,371 INFO sqlalchemy.engine.Engine [raw sql] ()
INFO:sqlalchemy.engine.Engine:[raw sql] ()
(...)

on this parts I've got an error

Traceback (most recent call last):
  File "/home/user/workspace.gcp/data_ai_agent_adk/global/deployment/deploy_agent.py", line 78, in <module>
    remote_app = agent_engines.update(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/workspace.gcp/data_ai_agent_adk/global/my_companion/.venv/lib/python3.12/site-packages/vertexai/agent_engines/__init__.py", line 383, in update
    return agent.update(
           ^^^^^^^^^^^^^
  File "/home/user/workspace.gcp/data_ai_agent_adk/global/my_companion/.venv/lib/python3.12/site-packages/vertexai/agent_engines/_agent_engines.py", line 836, in update
    created_resource = operation_future.result()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/workspace.gcp/data_ai_agent_adk/global/my_companion/.venv/lib/python3.12/site-packages/google/api_core/future/polling.py", line 261, in result
    raise self._exception
google.api_core.exceptions.InvalidArgument: 400 The Reasoning Engine failed to be updated.
 Please refer to our documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/troubleshooting/deploy) for checking logs and other troubleshooting tips. 3: The Reasoning Engine failed to be updated.

In the project where the agent is deployed, I've got more errors:

Image

Desktop (please complete the following information):

  • OS: [e.g. macOS, Linux, Windows] : GCP Workstation
  • Python version(python -V):Python 3.12.3
  • ADK version(pip show google-adk):1.17.0

Model Information:

  • Are you using LiteLLM: Yes/No : No
  • Which model is being used(e.g. gemini-2.5-pro) Gemini-2.5-Flash

Additional context
N/A

Metadata

Metadata

Assignees

Labels

services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions