Skip to content

Commit 9eb0515

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: Add enable_a2a option to adk command line
PiperOrigin-RevId: 775991652
1 parent 77b6168 commit 9eb0515

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
5656
EXPOSE {port}
5757
58-
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} "/app/agents"
58+
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} {a2a_option}"/app/agents"
5959
"""
6060

6161
_AGENT_ENGINE_APP_TEMPLATE = """
@@ -128,6 +128,7 @@ def to_cloud_run(
128128
session_service_uri: Optional[str] = None,
129129
artifact_service_uri: Optional[str] = None,
130130
memory_service_uri: Optional[str] = None,
131+
a2a: bool = False,
131132
):
132133
"""Deploys an agent to Google Cloud Run.
133134
@@ -189,6 +190,7 @@ def to_cloud_run(
189190
allow_origins_option = (
190191
f'--allow_origins={",".join(allow_origins)}' if allow_origins else ''
191192
)
193+
a2a_option = '--a2a' if a2a else ''
192194
dockerfile_content = _DOCKERFILE_TEMPLATE.format(
193195
gcp_project_id=project,
194196
gcp_region=region,
@@ -206,6 +208,7 @@ def to_cloud_run(
206208
allow_origins_option=allow_origins_option,
207209
adk_version=adk_version,
208210
host_option=host_option,
211+
a2a_option=a2a_option,
209212
)
210213
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
211214
os.makedirs(temp_folder, exist_ok=True)

src/google/adk/cli/cli_tools_click.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,13 @@ def decorator(func):
576576
" for Cloud Run."
577577
),
578578
)
579+
@click.option(
580+
"--a2a",
581+
is_flag=True,
582+
show_default=True,
583+
default=False,
584+
help="Optional. Whether to enable A2A endpoint.",
585+
)
579586
@functools.wraps(func)
580587
def wrapper(*args, **kwargs):
581588
return func(*args, **kwargs)
@@ -617,6 +624,7 @@ def cli_web(
617624
memory_service_uri: Optional[str] = None,
618625
session_db_url: Optional[str] = None, # Deprecated
619626
artifact_storage_uri: Optional[str] = None, # Deprecated
627+
a2a: bool = False,
620628
):
621629
"""Starts a FastAPI server with Web UI for agents.
622630
@@ -663,6 +671,9 @@ async def _lifespan(app: FastAPI):
663671
web=True,
664672
trace_to_cloud=trace_to_cloud,
665673
lifespan=_lifespan,
674+
a2a=a2a,
675+
host=host,
676+
port=port,
666677
)
667678
config = uvicorn.Config(
668679
app,
@@ -709,6 +720,7 @@ def cli_api_server(
709720
memory_service_uri: Optional[str] = None,
710721
session_db_url: Optional[str] = None, # Deprecated
711722
artifact_storage_uri: Optional[str] = None, # Deprecated
723+
a2a: bool = False,
712724
):
713725
"""Starts a FastAPI server for agents.
714726
@@ -733,6 +745,9 @@ def cli_api_server(
733745
allow_origins=allow_origins,
734746
web=False,
735747
trace_to_cloud=trace_to_cloud,
748+
a2a=a2a,
749+
host=host,
750+
port=port,
736751
),
737752
host=host,
738753
port=port,
@@ -854,6 +869,7 @@ def cli_deploy_cloud_run(
854869
eval_storage_uri: Optional[str] = None,
855870
session_db_url: Optional[str] = None, # Deprecated
856871
artifact_storage_uri: Optional[str] = None, # Deprecated
872+
a2a: bool = False,
857873
):
858874
"""Deploys an agent to Cloud Run.
859875
@@ -884,6 +900,7 @@ def cli_deploy_cloud_run(
884900
session_service_uri=session_service_uri,
885901
artifact_service_uri=artifact_service_uri,
886902
memory_service_uri=memory_service_uri,
903+
a2a=a2a,
887904
)
888905
except Exception as e:
889906
click.secho(f"Deploy failed: {e}", fg="red", err=True)

src/google/adk/cli/fast_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def get_fast_api_app(
204204
eval_storage_uri: Optional[str] = None,
205205
allow_origins: Optional[list[str]] = None,
206206
web: bool,
207+
a2a: bool = False,
208+
host: str = "127.0.0.1",
209+
port: int = 8000,
207210
trace_to_cloud: bool = False,
208211
lifespan: Optional[Lifespan[FastAPI]] = None,
209212
) -> FastAPI:

0 commit comments

Comments
 (0)