Python: A2AAgent defaults name/description from AgentCard#4661
Merged
giles17 merged 2 commits intomicrosoft:mainfrom Mar 13, 2026
Merged
Python: A2AAgent defaults name/description from AgentCard#4661giles17 merged 2 commits intomicrosoft:mainfrom
giles17 merged 2 commits intomicrosoft:mainfrom
Conversation
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>
Member
Contributor
There was a problem hiding this comment.
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 toagent_card.name/agent_card.descriptionwhen not explicitly provided. - Update
A2AAgentdocstring to document the new defaulting behavior. - Add unit tests covering defaulting and explicit override, and update an existing
AgentCardmock 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>
moonbox3
approved these changes
Mar 12, 2026
dmytrostruk
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When constructing an
A2AAgentwith anagent_card, users must redundantly passnameanddescriptioneven though theAgentCardalready contains this information. This is especially problematic when usingA2AAgentas a participant inGroupChatorchestrations, where the agent's name and description are essential for routing decisions.Fixes #4630
Description
When
agent_cardis provided andname/descriptionare not explicitly set,A2AAgent.__init__()now falls back toagent_card.nameandagent_card.description. Explicit values still take precedence, so this change is fully backward compatible.Changes:
A2AAgent.__init__()before thesuper().__init__()callname/descriptionattributesContribution Checklist