Commit d1b55cf
fix: use official A2A SDK for spec-compliant client implementation (#90)
* fix: refactor A2A adapter to use official a2a-sdk client
Replace custom HTTP client implementation with official A2A SDK:
**Adapter Changes:**
- Use `A2AClient` and `A2ACardResolver` from a2a-sdk
- Replace manual HTTP requests with official SDK methods
- Use A2A SDK types (Task, Message, TextPart, DataPart, etc.)
- Fix TaskState enum usage (lowercase strings not attributes)
- Fix Pydantic attribute access (snake_case not camelCase)
- Handle Part union type wrapper (access via .root)
**Benefits:**
- Spec-compliant: Uses canonical A2A client implementation
- Maintainable: No custom HTTP client code to maintain
- Type-safe: Leverages A2A SDK Pydantic models
- Future-proof: Auto-updates with A2A spec changes
**Test Updates:**
- Add helper functions for creating mock A2A responses
- Update all 12 A2A tests to use SDK types
- Mock `_get_a2a_client` instead of HTTP layer
- All 27 protocol tests passing (12 A2A + 15 MCP)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: resolve ruff and mypy errors in A2A adapter
Fixed linting and type checking issues:
- Removed unused imports (SendMessageSuccessResponse, TaskState)
- Added missing imports (MessageSendParams, Part, Role)
- Fixed Message construction to use snake_case field names
- Wrapped TextPart in Part union type as required by SDK
- Used Role.user enum instead of string literal
- Fixed line length by extracting agent_id to variable
- Fixed AgentCard.extensions access with getattr for runtime safety
- Fixed debug_request type annotation to avoid None issues
All ruff and mypy checks now pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: unwrap SendMessageResponse RootModel in A2A adapter
The A2A SDK's SendMessageResponse is a Pydantic RootModel that wraps
a union of JSONRPCSuccessResponse and JSONRPCErrorResponse. We need
to unwrap the .root attribute to access the actual response object
with .result or .error attributes.
This fix enables proper error handling and response processing when
communicating with A2A agents.
Verified against test-agent.adcontextprotocol.org:
- get_info() works ✓
- list_tools() works ✓
- Tool calls now properly return authentication errors instead of
"Invalid response from A2A client"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: use explicit skill invocation for A2A tool calls
Implement explicit skill invocation (deterministic) by default for A2A
protocol, as recommended by the A2A specification. This uses DataPart
with skill name and parameters instead of natural language interpretation.
**Changes:**
- Add `use_explicit_skill` parameter to `_call_a2a_tool` (default: True)
- Explicit mode: Send DataPart with `{"skill": "...", "parameters": {...}}`
- Natural language mode: Send TextPart with formatted text (legacy)
- Import DataPart from a2a.types
**Benefits:**
- Works without authentication for discovery endpoints (test agent)
- Predictable, repeatable behavior
- Direct skill execution without AI interpretation overhead
- Aligns with A2A best practices
**Reference:**
https://docs.adcontextprotocol.org/docs/protocols/a2a-guide
**Testing:**
- ✅ list_authorized_properties works without auth
- ✅ list_creative_formats works without auth
- ✅ get_products validates parameters correctly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 27ff0ae commit d1b55cf
2 files changed
+522
-485
lines changed
0 commit comments