Skip to content

fix(a2a): stamp A2A-Version on the rebound client with a2a-sdk 1.3 - #7777

Open
iamthehimansh wants to merge 1 commit into
google:mainfrom
iamthehimansh:fix/a2a-version-header-sdk-1-3
Open

iamthehimansh wants to merge 1 commit into
google:mainfrom
iamthehimansh:fix/a2a-version-header-sdk-1-3

Conversation

@iamthehimansh

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
With a2a-sdk 1.3.0 (released 2026-10-27, allowed by a2a-sdk>=0.3.4,<2), a RemoteA2aAgent built with a caller-supplied a2a_client_factory sends its requests without the A2A-Version header.

_compat.rebind_client_factory_httpx copies the caller's factory onto ADK's own httpx.AsyncClient. It stamped A2A-Version only inside if hasattr(new_factory, "_httpx_client"). In 1.3.0, ClientFactory.__init__ no longer creates or stores self._httpx_client. It stamps the header only on config.httpx_client (here None) and resolves a client per transport in the new _resolve_http_client(). So the attribute check is now always false, and the rebound client never gets the header.

The same thing shows as a failing unit test on main with 1.3.0:

FAILED tests/unittests/a2a/agent/test_remote_a2a_agent.py::TestRemoteA2aAgentResolution::test_ensure_resolved_uses_custom_factory
E   AttributeError: 'CustomFactory' object has no attribute '_httpx_client'

Solution:

  • rebind_client_factory_httpx: still rebind _httpx_client when the factory has it (a2a-sdk 1.0 to 1.2), but stamp A2A-Version on the rebound client whenever IS_A2A_V1, independent of that attribute. 0.3.x behaviour is unchanged.
  • New test test_rebind_client_factory_httpx_sets_version_header_on_new_client covers the header directly.
  • test_ensure_resolved_uses_custom_factory read the header through the factory's private _httpx_client, which 1.3.0 removed. It now checks the same header on agent._httpx_client, the client ADK actually sends with. This works on both 1.2.x and 1.3.0.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

All runs on macOS 26 (arm64), Python 3.13.15, pip install -e '.[test]'.

Run a2a-sdk 1.3.0 a2a-sdk 1.2.3
The 2 tests, fix reverted (tests kept) 2 failed 2 passed
The 2 tests, with fix 2 passed 2 passed
pytest tests/unittests/a2a with fix 963 passed, 57 skipped 963 passed, 57 skipped

pyink --check and isort --check-only (repo config) pass on the 3 changed files.

For reference, the full pytest tests/unittests run on main with a2a-sdk 1.3.0 on macOS had 14 failures: this one, and 13 in tests/unittests/integrations/vmaas/test_agent_engine_environment.py. The 13 are macOS-only and unrelated: that test runs the sandbox's commands in the local bash, and macOS stat/base64 don't accept stat -c / base64 -d <file>.

Manual End-to-End (E2E) Tests:

The header on the client RemoteA2aAgent sends with, after _ensure_resolved(), with a2a-sdk 1.3.0:

before:  no factory: A2A-Version = '1.0'
         a2a_client_factory=ClientFactory(ClientConfig(httpx_client=None)): A2A-Version = None
after:   no factory: A2A-Version = '1.0'
         a2a_client_factory=ClientFactory(ClientConfig(httpx_client=None)): A2A-Version = '1.0'

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

AI use: this PR was prepared with an AI assistant. It found the problem by running the unit suite and diffing a2a/client/client_factory.py between a2a-sdk 1.2.3 and 1.3.0, wrote the change and tests, and ran every command shown above on my machine (macOS 26.6.2, arm64). The output above is from those runs.

AI-assisted: yes (Cana)

a2a-sdk 1.3.0 no longer stores ClientFactory._httpx_client, so
rebind_client_factory_httpx never set A2A-Version on the httpx client a
RemoteA2aAgent sends with when a caller passed its own client factory.
Stamp the header whenever the SDK is 1.x, independent of that attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant