From e0ee6290629c3cb2c1a2ed03787244be2204531e Mon Sep 17 00:00:00 2001 From: devxaitist Date: Wed, 23 Apr 2025 00:03:54 +0900 Subject: [PATCH 1/2] fix: add missing --agent_engine_id option to deploy cloud_run command Add the --agent_engine_id option to the deploy cloud_run CLI command that was documented but not implemented. This allows users to connect their deployed agent to a Vertex AI Agent Engine for session persistence. Part of #303 --- src/google/adk/cli/cli_tools_click.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/google/adk/cli/cli_tools_click.py b/src/google/adk/cli/cli_tools_click.py index 2583dc79..66c4a872 100644 --- a/src/google/adk/cli/cli_tools_click.py +++ b/src/google/adk/cli/cli_tools_click.py @@ -541,6 +541,11 @@ def cli_api_server( default="WARNING", help="Optional. Override the default verbosity level.", ) +@click.option( + "--agent_engine_id", + type=str, + help="Optional. The Vertex AI Agent Engine ID to use. if set, the agent will be deployed to a managed session service.", +) @click.argument( "agent", type=click.Path( @@ -553,6 +558,7 @@ def cli_deploy_cloud_run( region: Optional[str], service_name: str, app_name: str, + agent_engine_id: str, temp_folder: str, port: int, trace_to_cloud: bool, @@ -574,6 +580,7 @@ def cli_deploy_cloud_run( region=region, service_name=service_name, app_name=app_name, + agent_engine_id=agent_engine_id, temp_folder=temp_folder, port=port, trace_to_cloud=trace_to_cloud, From 585fd31fe712344afbebcb2d57cf49f41e50bfc1 Mon Sep 17 00:00:00 2001 From: devxaitist Date: Wed, 23 Apr 2025 00:07:57 +0900 Subject: [PATCH 2/2] feat(deploy): implement agent_engine_id in Dockerfile template Update the Dockerfile template to use the agent_engine_id parameter by converting it to the required session_db_url format. This enables proper connection to Vertex AI Agent Engine when deploying to Cloud Run. Fixes #303 --- src/google/adk/cli/cli_deploy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/google/adk/cli/cli_deploy.py b/src/google/adk/cli/cli_deploy.py index 33573c89..a10ae08e 100644 --- a/src/google/adk/cli/cli_deploy.py +++ b/src/google/adk/cli/cli_deploy.py @@ -54,7 +54,7 @@ EXPOSE {port} -CMD adk {command} --port={port} {trace_to_cloud_option} "/app/agents" +CMD adk {command} {agent_engine_id_option} --port={port} {trace_to_cloud_option} "/app/agents" """ @@ -80,6 +80,7 @@ def to_cloud_run( region: Optional[str], service_name: str, app_name: str, + agent_engine_id: str, temp_folder: str, port: int, trace_to_cloud: bool, @@ -145,6 +146,7 @@ def to_cloud_run( command='web' if with_ui else 'api_server', install_agent_deps=install_agent_deps, trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '', + agent_engine_id_option=f'--session_db_url=agentengine://{agent_engine_id}' if agent_engine_id else '', ) dockerfile_path = os.path.join(temp_folder, 'Dockerfile') os.makedirs(temp_folder, exist_ok=True)