Skip to content

Python: A2AAgent defaults name/description from AgentCard#4661

Merged
giles17 merged 2 commits intomicrosoft:mainfrom
giles17:a2a-agent-card-name
Mar 13, 2026
Merged

Python: A2AAgent defaults name/description from AgentCard#4661
giles17 merged 2 commits intomicrosoft:mainfrom
giles17:a2a-agent-card-name

Conversation

@giles17
Copy link
Contributor

@giles17 giles17 commented Mar 12, 2026

Motivation and Context

When constructing an A2AAgent with an agent_card, users must redundantly pass name and description even though the AgentCard already contains this information. This is especially problematic when using A2AAgent as a participant in GroupChat orchestrations, where the agent's name and description are essential for routing decisions.

Fixes #4630

Description

When agent_card is provided and name/description are not explicitly set, A2AAgent.__init__() now falls back to agent_card.name and agent_card.description. Explicit values still take precedence, so this change is fully backward compatible.

Changes:

  • Added fallback logic in A2AAgent.__init__() before the super().__init__() call
  • Updated docstring to document the defaulting behavior
  • Added two new unit tests: one for defaulting from card, one for explicit override
  • Fixed existing test mock to include name/description attributes

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No, this is backward compatible.

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 microsoft#4630

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 12, 2026 20:52
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Mar 12, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/a2a/agent_framework_a2a
   _agent.py1831392%371, 392, 413, 433, 447, 461, 473–474, 515–516, 545–547
TOTAL23597261688% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5157 20 💤 0 ❌ 0 🔥 1m 32s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Python A2A integration so A2AAgent can automatically derive its name/description from an provided AgentCard, improving ergonomics for orchestrations (e.g., GroupChat) where these fields are used for routing.

Changes:

  • Add A2AAgent.__init__() fallback to agent_card.name / agent_card.description when not explicitly provided.
  • Update A2AAgent docstring to document the new defaulting behavior.
  • Add unit tests covering defaulting and explicit override, and update an existing AgentCard mock used in transport negotiation tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/a2a/agent_framework_a2a/_agent.py Implements name/description defaulting from AgentCard and documents it.
python/packages/a2a/tests/test_a2a_agent.py Adds tests for the new behavior and fixes an AgentCard mock to include required fields.

You can also share your feedback on Copilot code review. Take the survey.

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>
@giles17 giles17 enabled auto-merge March 12, 2026 21:03
@giles17 giles17 added this pull request to the merge queue Mar 13, 2026
Merged via the queue into microsoft:main with commit f696ac9 Mar 13, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: A2AAgent should default name/description from AgentCard when not explicitly provided

5 participants