Skip to content

fix(a2a): default AgentCardBuilder capabilities to streaming=True - #6673

Open
chelsealong wants to merge 1 commit into
google:mainfrom
chelsealong:fix-a2a-card-streaming-capability-6672
Open

fix(a2a): default AgentCardBuilder capabilities to streaming=True#6673
chelsealong wants to merge 1 commit into
google:mainfrom
chelsealong:fix-a2a-card-streaming-capability-6672

Conversation

@chelsealong

Copy link
Copy Markdown

Fixes #6672

Problem

An agent published with to_a2a() serves an agent card whose
capabilities.streaming is false, even though the handler to_a2a()
mounts (DefaultRequestHandler) implements message/stream. Peers that
read 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__ defaulted
self._capabilities to AgentCapabilities() (which itself defaults
streaming=False) whenever the caller didn't pass capabilities
explicitly, and to_a2a() never passes capabilities to
AgentCardBuilder. Since _compat.build_agent_card() uses the passed
capabilities object directly (falling back to its own streaming
default only when capabilities is None), the always-non-None
default from AgentCardBuilder silently pinned every to_a2a() card
to streaming: false, regardless of what the mounted handler actually
supports.

Fix

AgentCardBuilder now defaults its capabilities to
AgentCapabilities(streaming=True) instead of AgentCapabilities().
This is the minimal change that makes the default card reflect
what to_a2a() actually serves. Callers who pass an explicit
capabilities= argument are unaffected.

Testing plan

Added an assertion to the existing
test_init_with_valid_agent test in
tests/unittests/a2a/utils/test_agent_card_builder.py asserting
builder._capabilities.streaming is True by default.

Verified the test fails without the fix and passes with it:

$ git stash push -- src/google/adk/a2a/utils/agent_card_builder.py
$ python3 -m pytest tests/unittests/a2a/utils/test_agent_card_builder.py::TestAgentCardBuilder::test_init_with_valid_agent -q
FAILED ...test_init_with_valid_agent - assert False is True
1 failed, 5 warnings in 2.19s
$ git stash pop
$ python3 -m pytest tests/unittests/a2a/utils/test_agent_card_builder.py::TestAgentCardBuilder::test_init_with_valid_agent -q
1 passed

Full a2a unit test suite passes with the fix applied:

$ python3 -m pytest tests/unittests/a2a/ -q
441 passed, 45 skipped, 691 warnings in 4.63s

isort and pyink (per this repo's pre-commit config) report both
changed 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.

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
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_a2a() serves an agent card with capabilities.streaming=false while the mounted handler implements message/stream

3 participants