Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/google/adk/cli/cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

EXPOSE {port}

CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} {a2a_option} "/app/agents"
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {otel_to_cloud_option} {allow_origins_option} {a2a_option} "/app/agents"
"""

_AGENT_ENGINE_APP_TEMPLATE: Final[str] = """
Expand Down Expand Up @@ -487,6 +487,7 @@ def to_cloud_run(
temp_folder: str,
port: int,
trace_to_cloud: bool,
otel_to_cloud: bool,
with_ui: bool,
log_level: str,
verbosity: str,
Expand Down Expand Up @@ -523,6 +524,8 @@ def to_cloud_run(
temp_folder: The temp folder for the generated Cloud Run source files.
port: The port of the ADK api server.
trace_to_cloud: Whether to enable Cloud Trace.
otel_to_cloud: Whether to enable exporting OpenTelemetry signals
to Google Cloud.
with_ui: Whether to deploy with UI.
verbosity: The verbosity level of the CLI.
adk_version: The ADK version to use in Cloud Run.
Expand Down Expand Up @@ -580,6 +583,7 @@ def to_cloud_run(
use_local_storage,
),
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
otel_to_cloud_option='--otel_to_cloud' if otel_to_cloud else '',
allow_origins_option=allow_origins_option,
adk_version=adk_version,
host_option=host_option,
Expand Down Expand Up @@ -956,6 +960,7 @@ def to_gke(
temp_folder: str,
port: int,
trace_to_cloud: bool,
otel_to_cloud: bool,
with_ui: bool,
log_level: str,
adk_version: str,
Expand All @@ -981,6 +986,8 @@ def to_gke(
Dockerfile and deployment.yaml.
port: The port of the ADK api server.
trace_to_cloud: Whether to enable Cloud Trace.
otel_to_cloud: Whether to enable exporting OpenTelemetry signals
to Google Cloud.
with_ui: Whether to deploy with UI.
log_level: The logging level.
adk_version: The ADK version to use in GKE.
Expand Down Expand Up @@ -1051,6 +1058,7 @@ def to_gke(
use_local_storage,
),
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
otel_to_cloud_option='--otel_to_cloud' if otel_to_cloud else '',
allow_origins_option=allow_origins_option,
adk_version=adk_version,
host_option=host_option,
Expand Down
18 changes: 18 additions & 0 deletions src/google/adk/cli/cli_tools_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,13 @@ def cli_api_server(
default=False,
help="Optional. Whether to enable Cloud Trace for cloud run.",
)
@click.option(
"--otel_to_cloud",
is_flag=True,
show_default=True,
default=False,
help="Optional. Whether to enable OpenTelemetry for Agent Engine.",
)
@click.option(
"--with_ui",
is_flag=True,
Expand Down Expand Up @@ -1450,6 +1457,7 @@ def cli_deploy_cloud_run(
temp_folder: str,
port: int,
trace_to_cloud: bool,
otel_to_cloud: bool,
with_ui: bool,
adk_version: str,
log_level: str,
Expand Down Expand Up @@ -1528,6 +1536,7 @@ def cli_deploy_cloud_run(
temp_folder=temp_folder,
port=port,
trace_to_cloud=trace_to_cloud,
otel_to_cloud=otel_to_cloud,
allow_origins=allow_origins,
with_ui=with_ui,
log_level=log_level,
Expand Down Expand Up @@ -1799,6 +1808,13 @@ def cli_deploy_agent_engine(
default=False,
help="Optional. Whether to enable Cloud Trace for GKE.",
)
@click.option(
"--otel_to_cloud",
is_flag=True,
show_default=True,
default=False,
help="Optional. Whether to enable OpenTelemetry for GKE.",
)
@click.option(
"--with_ui",
is_flag=True,
Expand Down Expand Up @@ -1855,6 +1871,7 @@ def cli_deploy_gke(
temp_folder: str,
port: int,
trace_to_cloud: bool,
otel_to_cloud: bool,
with_ui: bool,
adk_version: str,
log_level: Optional[str] = None,
Expand Down Expand Up @@ -1884,6 +1901,7 @@ def cli_deploy_gke(
temp_folder=temp_folder,
port=port,
trace_to_cloud=trace_to_cloud,
otel_to_cloud=otel_to_cloud,
with_ui=with_ui,
log_level=log_level,
adk_version=adk_version,
Expand Down
6 changes: 4 additions & 2 deletions src/google/adk/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ async def run_live(
raise ValueError(
'Either session or user_id and session_id must be provided.'
)
if live_request_queue is None:
raise ValueError('live_request_queue is required for run_live.')
if session is not None:
warnings.warn(
'The `session` parameter is deprecated. Please use `user_id` and'
Expand Down Expand Up @@ -1380,15 +1382,15 @@ def _new_invocation_context_for_live(
self,
session: Session,
*,
live_request_queue: Optional[LiveRequestQueue] = None,
live_request_queue: LiveRequestQueue,
run_config: Optional[RunConfig] = None,
) -> InvocationContext:
"""Creates a new invocation context for live multi-agent."""
run_config = run_config or RunConfig()

# For live multi-agents system, we need model's text transcription as
# context for the transferred agent.
if self.agent.sub_agents and live_request_queue:
if self.agent.sub_agents:
if 'AUDIO' in run_config.response_modalities:
if not run_config.output_audio_transcription:
run_config.output_audio_transcription = (
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/cli/utils/test_cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def mock_subprocess_run(*args, **kwargs):
temp_folder=str(tmp_path),
port=9090,
trace_to_cloud=False,
otel_to_cloud=False,
with_ui=True,
log_level="debug",
adk_version="1.2.0",
Expand Down
5 changes: 5 additions & 0 deletions tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def test_to_cloud_run_happy_path(
temp_folder=str(tmp_path),
port=8080,
trace_to_cloud=True,
otel_to_cloud=True,
with_ui=with_ui,
log_level="info",
verbosity="info",
Expand Down Expand Up @@ -154,6 +155,7 @@ def test_to_cloud_run_happy_path(
assert "ENV GOOGLE_CLOUD_LOCATION=asia-northeast1" in dockerfile_content
assert "RUN pip install google-adk==1.3.0" in dockerfile_content
assert "--trace_to_cloud" in dockerfile_content
assert "--otel_to_cloud" in dockerfile_content

# Check agent dependencies installation based on include_requirements
if include_requirements:
Expand Down Expand Up @@ -220,6 +222,7 @@ def _fake_rmtree(path: str | Path, *_a: Any, **_k: Any) -> None:
temp_folder=str(tmp_dir),
port=8080,
trace_to_cloud=False,
otel_to_cloud=False,
with_ui=False,
log_level="info",
verbosity="info",
Expand Down Expand Up @@ -258,6 +261,7 @@ def test_to_cloud_run_cleans_temp_dir_on_failure(
temp_folder=str(tmp_dir),
port=8080,
trace_to_cloud=False,
otel_to_cloud=False,
with_ui=False,
log_level="info",
verbosity="info",
Expand Down Expand Up @@ -326,6 +330,7 @@ def test_cloud_run_label_merging(
temp_folder=str(tmp_path),
port=8080,
trace_to_cloud=False,
otel_to_cloud=False,
with_ui=False,
log_level="info",
verbosity="info",
Expand Down
Loading