google / google/adk-python

to_a2a(): accept a service_url string instead of separate host/port/protocol params

オープン
#5,060 コメント 2 件 リアクション 0 件 担当者 2 名 @ankursharmas が担当を希望しています GitHub で見る
core needs review
主要言語
Python
スター
21.5k
フォーク
4k
平均マージ
1日 22時間
マージ済み PR(30日)
31

説明

## Feature request

`to_a2a()` currently requires `host`, `port`, and `protocol` as separate parameters:

```python
app = to_a2a(
root_agent,
host="localhost",
port=8002,
protocol="http",
runner=_create_runner,
agent_card=agent_card,
)
```

In practice, the service URL is typically available as a single string (e.g. `SERVICE_URL=http://localhost:8002` for local dev, or `https://my-agent.europe-west1.run.app` on Cloud Run). This forces every consumer to manually parse the URL with `urlparse()` to extract the three components:

```python
parsed = urlparse(settings.SERVICE_URL)
protocol = parsed.scheme or "http"
host = parsed.hostname or "localhost"
port = parsed.port or (443 if protocol == "https" else 80)
```

## Proposal

Accept an optional `service_url` parameter as an alternative to `host`/`port`/`protocol`:

```python
# New — single URL string
app = to_a2a(root_agent, service_url="http://localhost:8002", ...)

# Existing — still works
app = to_a2a(root_agent, host="localhost", port=8002, protocol="http", ...)
```

This would reduce boilerplate for Cloud Run, Kubernetes, and any deployment where the URL comes from an environment variable.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。