mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: A2AAgent defaults name/description from AgentCard (#4661)
* Python: A2AAgent defaults name/description from AgentCard When an AgentCard is provided but name/description are not explicitly set, A2AAgent now falls back to agent_card.name and agent_card.description. This avoids redundant duplication when constructing A2AAgent instances, especially in GroupChat orchestrations where name and description are essential for routing decisions. Explicit values still take precedence over card values. Fixes #4630 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use 'is None' checks instead of truthiness for name/description fallback Ensures explicitly provided empty strings are not overridden by agent_card values. Adds test for the empty string edge case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
5e33deff45
commit
f696ac9b57
@@ -114,9 +114,10 @@ class A2AAgent(AgentTelemetryLayer, BaseAgent):
|
||||
"""Initialize the A2AAgent.
|
||||
|
||||
Keyword Args:
|
||||
name: The name of the agent.
|
||||
name: The name of the agent. Defaults to agent_card.name if agent_card is provided.
|
||||
id: The unique identifier for the agent, will be created automatically if not provided.
|
||||
description: A brief description of the agent's purpose.
|
||||
description: A brief description of the agent's purpose. Defaults to agent_card.description
|
||||
if agent_card is provided.
|
||||
agent_card: The agent card for the agent.
|
||||
url: The URL for the A2A server.
|
||||
client: The A2A client for the agent.
|
||||
@@ -127,6 +128,13 @@ class A2AAgent(AgentTelemetryLayer, BaseAgent):
|
||||
10.0s write, 5.0s pool - optimized for A2A operations).
|
||||
kwargs: any additional properties, passed to BaseAgent.
|
||||
"""
|
||||
# Default name/description from agent_card when not explicitly provided
|
||||
if agent_card is not None:
|
||||
if name is None:
|
||||
name = agent_card.name
|
||||
if description is None:
|
||||
description = agent_card.description
|
||||
|
||||
super().__init__(id=id, name=name, description=description, **kwargs)
|
||||
self._http_client: httpx.AsyncClient | None = http_client
|
||||
self._timeout_config = self._create_timeout_config(timeout)
|
||||
|
||||
Reference in New Issue
Block a user