Skip to content

Commit 5cd7e0e

Browse files
bokelleyclaude
andcommitted
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>
1 parent c703600 commit 5cd7e0e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/adcp/protocols/a2a.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ async def _call_a2a_tool(self, tool_name: str, params: dict[str, Any]) -> TaskRe
150150

151151
try:
152152
# Use official A2A client
153-
response = await a2a_client.send_message(request)
153+
sdk_response = await a2a_client.send_message(request)
154+
155+
# SendMessageResponse is a RootModel union - unwrap it to get the actual response
156+
# (either JSONRPCSuccessResponse or JSONRPCErrorResponse)
157+
response = sdk_response.root if hasattr(sdk_response, "root") else sdk_response
154158

155159
# Handle JSON-RPC error response
156160
if hasattr(response, "error"):

0 commit comments

Comments
 (0)