fix: use official A2A SDK for spec-compliant client implementation #90
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.
Fix A2A Adapter by Using Official A2A SDK
Summary
Fixes the A2A protocol adapter implementation by using the official
a2a-sdkclient instead of a custom HTTP implementation. This resolves response parsing issues and ensures spec compliance.Changes
1. Refactor to Official SDK (
fix: refactor A2A adapter to use official a2a-sdk client)Adapter Changes:
A2AClientandA2ACardResolverfroma2a-sdkpackageTask,Message,TextPart,DataPart,Role, etc.)task.context_idnottask.contextId).root)Test Updates:
_get_a2a_clientinstead of HTTP layerBenefits:
2. CI Fixes (
fix: resolve ruff and mypy errors in A2A adapter)Fixed linting and type checking errors:
SendMessageSuccessResponse,TaskState)MessageSendParams,Part,Role)TextPartinPartunion type as required by SDKRole.userenum instead of string literalAgentCard.extensionsaccess withgetattrfor runtime safetyAll ruff and mypy checks pass ✓
3. Response Handling Fix (
fix: unwrap SendMessageResponse RootModel in A2A adapter)Critical Bug Fix:
The A2A SDK's
SendMessageResponseis a PydanticRootModelthat wraps a union ofJSONRPCSuccessResponse | JSONRPCErrorResponse. The adapter was trying to access.erroror.resultdirectly on the wrapper, which doesn't have these attributes.Solution:
This enables proper response handling for both success and error cases.
Testing
Verified against test agent at
https://test-agent.adcontextprotocol.org:Without Authentication:
get_info()- Successfully retrieves agent metadatalist_tools()- Successfully lists 16 available toolsWith Bearer Token Authentication:
get_products()- Successfully retrieved 2 products with full dataAuthorization: Bearer <token>CI Checks:
Release Type
This is a patch release (2.12.1 → 2.12.2) containing bug fixes to make the A2A adapter work correctly with the official SDK.