-
Notifications
You must be signed in to change notification settings - Fork 437
Description
Bug Description
When deploying an ADK agent to Vertex AI Agent Engine (Reasoning Engine) with GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY=true, the set_up() method fails with:
ValueError: When providing a transport instance, provide its credentials directly.
The agent never starts and the service terminates immediately.
Full Traceback
File "/code/app/api/factory/python_file_api_builder.py", line 1090, in create_apis_from_object
obj.set_up()
File "/code/app/agent_engine_app.py", line 37, in set_up
super().set_up()
File "/code/.venv/lib/python3.12/site-packages/vertexai/agent_engines/templates/adk.py", line 858, in set_up
self._tmpl_attrs["instrumentor"] = custom_instrumentor(self.project_id())
File "/code/app/api/telemetry_utils.py", line 296, in default_exporters_setup
return _default_exporters_setup(
File "/code/app/api/telemetry_utils.py", line 395, in _default_exporters_setup
_setup_logging(agent_engine, project_id, resource, credentials)
File "/code/app/api/telemetry_utils.py", line 539, in _setup_logging
client=logging_service_v2.LoggingServiceV2Client(
File "/code/.venv/lib/python3.12/site-packages/google/cloud/logging_v2/services/logging_service_v2/client.py", line 638, in __init__
raise ValueError(
ValueError: When providing a transport instance, provide its credentials directly.
Root Cause
The Agent Engine runtime's server-side telemetry_utils.py (/code/app/api/telemetry_utils.py) injects default_exporters_setup as the instrumentor_builder. When GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY=true, adk.py:858 calls this instrumentor, which reaches _setup_logging and creates a LoggingServiceV2Client passing both a transport instance and credentials simultaneously.
LoggingServiceV2Client.__init__ has always rejected this combination (confirmed present since at least v3.11.4 of google-cloud-logging):
transport_provided = isinstance(transport, LoggingServiceV2Transport)
if transport_provided:
if credentials or self._client_options.credentials_file or api_key_value:
raise ValueError(
"When providing a transport instance, "
"provide its credentials directly."
)This is a bug in the Agent Engine runtime's telemetry_utils.py — it should not pass credentials alongside a transport instance. The bug cannot be reproduced locally because the runtime only injects default_exporters_setup as the instrumentor_builder inside the deployed container; locally instrumentor_builder is None and _default_instrumentor_builder (from the SDK) is used instead without issue.
Environment
- google-cloud-aiplatform: 1.138.0
- google-cloud-logging: 3.13.0
- Python: 3.12 (in deployed container)
- Deployment target: Vertex AI Agent Engine / Reasoning Engine (
aiplatform.googleapis.com/ReasoningEngine) - Region: us-central1
Workaround
Set GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY=false as a deployment env var to prevent the broken runtime telemetry code path from running. This disables the Agent Engine's built-in Cloud Trace/Logging integration.