Skip to content

Commit 65484a8

Browse files
fix(a2a): preserve discovery name edit, default discovery headers, sync url on re-discover
- _build_merged_agent_card: prefer card-supplied name over agent_name so the discovery panel's editable 'Name (shown to API clients)' value is not silently overwritten by the internal identifier. - async_safe_get call in fetch_well_known_card: pass headers or {} to avoid TypeError({**None, 'Host': ...}) when URL validation is enabled in production (default). - agent_info handleApplyDiscoveredCard: set url: selection.upstream_url in fieldsToSet so re-discovery during edit refreshes the form's URL field for pure A2A agents (matches add_agent_form). Co-authored-by: Yassin Kortam <[email protected]>
1 parent 1a9bce3 commit 65484a8

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

litellm/proxy/a2a/discovery.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ async def fetch_well_known_card(
119119
# redirect hop. Even though the discovery endpoint is admin-only,
120120
# we don't want a compromised admin key to be able to probe
121121
# internal infrastructure through this fetcher.
122-
response = await async_safe_get(client, url, headers=headers)
122+
# Pass ``headers or {}`` because ``async_safe_get`` (in the
123+
# URL-validation path) uses ``kwargs.pop("headers", {})`` which
124+
# returns ``None`` when the key is present-but-None, then crashes
125+
# on ``{**None, "Host": ...}``. Default the kwarg to an empty
126+
# dict so production (``user_url_validation=True``) doesn't 500.
127+
response = await async_safe_get(client, url, headers=headers or {})
123128
except SSRFError as exc:
124129
last_error = f"{url}: {exc!s}"
125130
verbose_proxy_logger.debug(

litellm/proxy/agent_endpoints/endpoints.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ def _build_merged_agent_card(
5252
) -> Dict[str, Any]:
5353
"""Apply the LiteLLM-fronting merge to ``upstream_card`` for ``agent_id``."""
5454
proxy_base = _proxy_base_url(http_request)
55+
# Prefer a card-supplied ``name`` (the discovery UI exposes an editable
56+
# "Name (shown to API clients)" field that flows into
57+
# ``agent_card_params.name``) over the internal ``agent_name`` identifier.
58+
# Fall back to ``agent_name`` only when the card itself has no name.
59+
card_name = upstream_card.get("name") if upstream_card else None
5560
return merge_agent_card(
5661
upstream_card,
5762
proxy_url=f"{proxy_base}/a2a/{agent_id}",
5863
proxy_base_url=proxy_base,
59-
name=agent_name,
64+
name=card_name or agent_name,
6065
)
6166

6267

ui/litellm-dashboard/src/components/agents/agent_info.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const AgentInfoView: React.FC<AgentInfoViewProps> = ({
131131
const fieldsToSet: Record<string, any> = {
132132
name: selected_card.name,
133133
description: selected_card.description,
134+
url: selection.upstream_url,
134135
streaming: Boolean(selected_card.capabilities?.streaming),
135136
skills,
136137
iconUrl: selected_card.iconUrl,

0 commit comments

Comments
 (0)