Skip to content

ValueError when querying hosted ADK agent from Gemini Enterprise via Google Cloud Agent Engine #6036

@KenTandrian

Description

@KenTandrian

🔴 Required Information

Describe the Bug:
A ValueError is raised in google-adk version 2.2.0 when running an agent hosted on Agent Runtime -- formerly known as Agent Engine / Reasoning Engine (using Vertex AI managed sessions) and querying it from Gemini Enterprise App.

The fully qualified session resource path (which contains slashes /) was passed to the session service. This fails the strict session ID format check (_validate_session_id) added to vertex_ai_session_service.py in 2.2.0 (commit b2916c7).

Steps to Reproduce:

  1. Deploy a Python ADK agent using google-adk version 2.2.0 on Google Cloud Agent Runtime.
  2. Query the agent via the Gemini Enterprise app.
  3. The platform sends a fully qualified session path.
  4. The server throws a ValueError, seen in Google Cloud Logging.

Expected Behavior:
The SDK should either parse/sanitize the fully qualified resource name to extract the short session ID (last segment after /) before validation, or the validator should support full resource paths when invoked by the platform runner.

Observed Behavior:
The server crash logs show:

ValueError: Invalid session_id 'projects/my_project_number/locations/global/collections/default_collection/engines/my_app/sessions/my_session_id': must match ^[A-Za-z0-9_-]+$.

Environment Details:

  • ADK Library Version (pip show google-adk): 2.2.0
  • Desktop OS: macOS
  • Python Version (python -V): Python 3.11

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-3.5-flash

🟡 Optional Information

Regression:
Yes. This worked in google-adk versions prior to 2.2.0 where the _validate_session_id check was not yet present.
The regression was introduced in the commit: b2916c7 (related to #5580).

Logs:

File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/cli/fast_api.py", line 797, in json_generator
  async for chunk in output:
File "/home/myuser/.local/lib/python3.11/site-packages/vertexai/agent_engines/templates/adk.py", line 1342, in streaming_agent_run_with_events
  session = await session_service.get_session(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 181, in get_session
  _validate_session_id(session_id)
File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 58, in _validate_session_id
  raise ValueError(
ValueError: Invalid session_id 'projects/my_project_number/locations/global/collections/default_collection/engines/my_app/sessions/my_session_id': must match ^[A-Za-z0-9_-]+$.

Additional Context:
The commit b2916c7 added _validate_session_id to verify session IDs against ^[A-Za-z0-9_-]+$. However, the ADK runner forwards the full platform path to Vertex AI Session Service, bypassing any extraction, which leads to this crash in hosted environments.

How often has this issue occurred?:

  • Always (100%) when queried from platforms sending fully qualified paths (like Gemini Enterprise).
Image

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