Skip to content

RemoteA2aAgent crashes with AttributeError: status_code when an A2A call fails, masking the real error #6714

Closed

Description

@minikhEugene

Versions: google-adk 2.5.0, a2a-sdk 1.1.2, Python 3.12 (Agent Runtime container)

What happens: When a remote A2A call returns an HTTP error, the error handler in remote_a2a_agent.py:805 builds custom_metadata with str(e.status_code). With a2a-sdk v1, _compat.A2A_HTTP_ERRORS is (a2a.client.errors.A2AClientError,), and that class has no status_code attribute — it exposes only message and data. The handler therefore raises AttributeError while handling the original error.

The comment at google/adk/a2a/_compat.py:520 states A2AClientError "carries status_code attr". It does not.

Impact: The AttributeError propagates as DynamicNodeFailError: Dynamic node failed and surfaces as a 500 in the ASGI app. The user-visible result is an empty agent response with no error message. The actual cause (in my case an HTTP 401 from the peer) is only discoverable in the container logs. Any failing A2A call is silently swallowed.

Traceback:
File
".../google/adk/agents/remote_a2a_agent.py", line 744, in _run_async_impl
raise A2AClientError(f'HTTP Error {e.response.status_code}: {e}') from e
a2a.client.errors.A2AClientError: HTTP Error 401: Client error '401 Unauthorized' for url '...'

During handling of the above exception, another exception occurred: File ".../google/adk/agents/remote_a2a_agent.py", line 805, in _run_async_impl
AttributeError: 'A2AClientError' object has no attribute 'status_code'
google.adk.workflow._errors.DynamicNodeFailError: Dynamic node text_metrics_agent failed

Repro: Give a RemoteA2aAgent a peer whose endpoint returns any 4xx, and send it a message that triggers transfer_to_agent.

Suggested fix: In the v1 branch, either attach status_code when raising A2AClientError at line 744, or read it defensively in the handler (getattr(e, "status_code", None)). Also correct the misleading comment in _compat.py.

Activity

  1. chelsealong commented on Aug 13, 2026

    @chelsealong
    Contributor

    Following up on my own comment: after digging in, this is already fixed on main. _handle_a2a_response no longer does str(e.status_code); it reads status_code: object = getattr(e, "status_code", None) (src/google/adk/agents/remote_a2a_agent.py, added in commit b34c636, 2026-08-05), so the handler can no longer raise AttributeError on a v1 A2AClientError that lacks status_code. That commit predates this issue and didn't reference it, which is presumably why it wasn't caught by triage.

    The one thing still stale is the comment at _compat.py claiming A2AClientError "carries status_code attr" — it doesn't, and the code no longer relies on it being true. Minor, but worth a follow-up if someone wants to tidy it.

    Since the actual crash is resolved, I won't be opening a PR here. Apologies for the noise on the earlier claim comment.

  2. minikhEugene commented on Aug 13, 2026

    @minikhEugene
    Author

    @chelsealong thanks!
    Two corrections, for the record.

    The traceback in my issue body accidentally splices two frames: the raise A2AClientError(f'HTTP Error {e.response.status_code}: {e}') line is not in remote_a2a_agent.py:744, it lives in a2a-sdk, at a2a/client/transports/http_helpers.py:36. The frame that actually crashes, remote_a2a_agent.py:805, is accurate. Please disregard the "line 744" reference in my suggested fix.

    More usefully: the fix on main has not shipped yet. The latest release, google-adk 2.5.0, still has str(e.status_code) at remote_a2a_agent.py:805, that is the version my Agent Runtime container installs, and it produced this traceback. Is a release including b34c636 planned? Until it ships, any project pinning a released version still hits this.

    I'm happy to open the small follow-up PR for the stale _compat.py comment if that's welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions