fix(a2a): default AgentCardBuilder capabilities to streaming=True - #6673
Open
chelsealong wants to merge 1 commit into
Open
fix(a2a): default AgentCardBuilder capabilities to streaming=True#6673chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
to_a2a() always mounts a DefaultRequestHandler that implements message/stream, but AgentCardBuilder defaulted to AgentCapabilities() (streaming=False) whenever a caller didn't pass capabilities explicitly. Peers reading the served card were told streaming was unavailable and fell back to unary calls even though the server supported it. Fixes google#6672
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.
Fixes #6672
Problem
An agent published with
to_a2a()serves an agent card whosecapabilities.streamingisfalse, even though the handlerto_a2a()mounts (
DefaultRequestHandler) implementsmessage/stream. Peers thatread the card to decide how to call the agent are told streaming is
unavailable, so they fall back to unary calls and lose incremental output
for no reason.
Root cause:
AgentCardBuilder.__init__defaultedself._capabilitiestoAgentCapabilities()(which itself defaultsstreaming=False) whenever the caller didn't passcapabilitiesexplicitly, and
to_a2a()never passescapabilitiestoAgentCardBuilder. Since_compat.build_agent_card()uses the passedcapabilitiesobject directly (falling back to its ownstreamingdefault only when
capabilitiesisNone), the always-non-Nonedefault from
AgentCardBuildersilently pinned everyto_a2a()cardto
streaming: false, regardless of what the mounted handler actuallysupports.
Fix
AgentCardBuildernow defaults its capabilities toAgentCapabilities(streaming=True)instead ofAgentCapabilities().This is the minimal change that makes the default card reflect
what
to_a2a()actually serves. Callers who pass an explicitcapabilities=argument are unaffected.Testing plan
Added an assertion to the existing
test_init_with_valid_agenttest intests/unittests/a2a/utils/test_agent_card_builder.pyassertingbuilder._capabilities.streaming is Trueby default.Verified the test fails without the fix and passes with it:
Full
a2aunit test suite passes with the fix applied:isortandpyink(per this repo's pre-commit config) report bothchanged files as already formatted correctly.
AI-assistance disclosure
This change was prepared with the help of an AI coding agent
(Claude), including drafting the fix, tests, and this PR description.
The change was reviewed and verified locally before submission.