Environment
Description
When deploying the Agent2UI (A2UI) agent using the provided deployment/deploy.py --create script, it completes successfully, but the backend container crashes instantly. This results in a generic deployment failure surface: google.api_core.exceptions.InvalidArgument: 400 Reasoning Engine resource failed to start and cannot serve traffic.
Root Cause Analysis
- During the cloud container initialisation phase (
obj.set_up()), the Vertex AI runtime dynamically overrides the underlying application name property, forcing it to match the newly generated, purely numerical Vertex Reasoning Engine Resource ID (e.g., '3385786078794350592').
- The
google.adk framework uses Pydantic to validate its model architectures. The App model constructor enforces a strict validation parameter requiring the application name string to start with an alphabetic character.
- Because the platform-assigned numeric ID fails this regex check, Pydantic raises a fatal
ValidationError, causing the Uvicorn worker process to terminate immediately before loading user routes.
Log Excerpt (Cloud Logging Stderr)
"textPayload": "[23] ERROR: Error when setting up the application. Service terminating. Please check the `set_up` in: https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/develop/custom#deployment-considerations, fix the error in `set_up()` and re-deploy the application. Traceback: Traceback (most recent call last):\\n File \"/code/app/api/factory/python_file_api_builder.py\", line 1238, in create_apis_from_object\\n obj.set_up()\\n File \"/code/.venv/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py\", line 874, in set_up\\n self._tmpl_attrs[\"runner\"] = Runner(\\n ^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/google/adk/runners.py\", line 234, in __init__\\n app = self._resolve_app(app, app_name, agent, node, plugins)\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/google/adk/runners.py\", line 306, in _resolve_app\\n return App(name=app_name, root_agent=agent, plugins=plugins or [])\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/pydantic/main.py\", line 263, in __init__\\n validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\npydantic_core._pydantic_core.ValidationError: 1 validation error for App\\n Value error, Invalid app name '3385786078794350592': must start with a letter and can only consist of letters, digits, underscores, and hyphens. [type=value_error, input_value={'name': '338578607879435...ck=None), 'plugins': []}, input_type=dict]\\n For further information visit https://errors.pydantic.dev/2.13/v/value_error\\n",
Steps to Reproduce
- Set up a clean, modern Google Cloud Project.
- Follow the tutorial steps to execute
python3 deployment/deploy.py --create.
- Observe the deployment crash out with a
400 error as Vertex AI polls the un-bootable container for health checks.
Proven Workaround / Suggested Fix
The initialisation templates in the Vertex AI SDK or the google.adk framework runner initialization logic should automatically prepend a safe character prefix if the assigned runtime name is entirely numeric.
As a temporary solution, adding a monkey-patch to the very start of a2ui/agent.py to intercept the initialization keyword arguments successfully solves the validation failure and allows the app container to serve traffic normally:
try:
import google.adk.runners
if hasattr(google.adk.runners, 'App'):
TargetApp = google.adk.runners.App
original_init = TargetApp.__init__
def patched_init(self, *args, **kwargs):
# If the app name is a raw number string, prepend a letter to satisfy Pydantic
if 'name' in kwargs and str(kwargs['name']).isdigit():
kwargs['name'] = f"agent_{kwargs['name']}"
original_init(self, *args, **kwargs)
TargetApp.__init__ = patched_init
except Exception as patch_error:
pass
Environment
apps-script/chat/a2ui-ai-agent/a2uiDescription
When deploying the Agent2UI (A2UI) agent using the provided
deployment/deploy.py --createscript, it completes successfully, but the backend container crashes instantly. This results in a generic deployment failure surface:google.api_core.exceptions.InvalidArgument: 400 Reasoning Engine resource failed to start and cannot serve traffic.Root Cause Analysis
obj.set_up()), the Vertex AI runtime dynamically overrides the underlying application name property, forcing it to match the newly generated, purely numerical Vertex Reasoning Engine Resource ID (e.g.,'3385786078794350592').google.adkframework uses Pydantic to validate its model architectures. TheAppmodel constructor enforces a strict validation parameter requiring the application name string to start with an alphabetic character.ValidationError, causing the Uvicorn worker process to terminate immediately before loading user routes.Log Excerpt (Cloud Logging Stderr)
"textPayload": "[23] ERROR: Error when setting up the application. Service terminating. Please check the `set_up` in: https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/develop/custom#deployment-considerations, fix the error in `set_up()` and re-deploy the application. Traceback: Traceback (most recent call last):\\n File \"/code/app/api/factory/python_file_api_builder.py\", line 1238, in create_apis_from_object\\n obj.set_up()\\n File \"/code/.venv/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py\", line 874, in set_up\\n self._tmpl_attrs[\"runner\"] = Runner(\\n ^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/google/adk/runners.py\", line 234, in __init__\\n app = self._resolve_app(app, app_name, agent, node, plugins)\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/google/adk/runners.py\", line 306, in _resolve_app\\n return App(name=app_name, root_agent=agent, plugins=plugins or [])\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n File \"/code/.venv/lib/python3.11/site-packages/pydantic/main.py\", line 263, in __init__\\n validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\npydantic_core._pydantic_core.ValidationError: 1 validation error for App\\n Value error, Invalid app name '3385786078794350592': must start with a letter and can only consist of letters, digits, underscores, and hyphens. [type=value_error, input_value={'name': '338578607879435...ck=None), 'plugins': []}, input_type=dict]\\n For further information visit https://errors.pydantic.dev/2.13/v/value_error\\n",Steps to Reproduce
python3 deployment/deploy.py --create.400error as Vertex AI polls the un-bootable container for health checks.Proven Workaround / Suggested Fix
The initialisation templates in the Vertex AI SDK or the
google.adkframework runner initialization logic should automatically prepend a safe character prefix if the assigned runtime name is entirely numeric.As a temporary solution, adding a monkey-patch to the very start of
a2ui/agent.pyto intercept the initialization keyword arguments successfully solves the validation failure and allows the app container to serve traffic normally: