adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

fix(agents): tolerate empty A2A message parts in RemoteA2aAgent

Open saurabhhhcodes opened this issue 6 days ago • 2 comments

Fixes an IndexError when handling initial A2A TASK_REQUIRED responses that contain no message parts. The handler now checks for empty parts before accessing them and marks all present parts as thought for submitted tasks. Added a unit test covering the empty-parts scenario.\n\nTesting plan:\n- Unit test added: tests/unittests/agents/test_remote_a2a_agent.py (new case in TestRemoteA2aAgentMessageHandling).\n- Run tests locally with dev environment active: PYTHONPATH=src pytest tests/unittests/agents/test_remote_a2a_agent.py -q or run the single new test as needed.\n- CI will run full test matrix; this change is small and focused.

Testing

  • Added unit test: tests/unittests/agents/test_remote_a2a_agent.py covering empty-parts TASK_REQUIRED.
  • Local run: pytest tests/unittests/agents/test_remote_a2a_agent.py70 passed, 81 warnings.
  • Change: guard against empty event.content.parts in RemoteA2aAgent._handle_a2a_response to avoid IndexError.

Testing

  • Added unit test: tests/unittests/agents/test_remote_a2a_agent.py covering empty-parts TASK_REQUIRED.
  • Local run: pytest tests/unittests/agents/test_remote_a2a_agent.py70 passed, 81 warnings.
  • Change: guard against empty event.content.parts in RemoteA2aAgent._handle_a2a_response to avoid IndexError.

saurabhhhcodes avatar Dec 02 '25 08:12 saurabhhhcodes

Response from ADK Triaging Agent

Hello @saurabhhhcodes, thank you for creating this PR!

To help reviewers understand how you've tested these changes, could you please add a "Testing Plan" section to your PR description? You can find more details in our contribution guidelines.

Thank you!

adk-bot avatar Dec 02 '25 08:12 adk-bot

Summary: Fix IndexError in RemoteA2aAgent when A2A TASK responses have empty parts.

What changed:

  • Guard against empty event.content.parts when handling TASK_REQUIRED responses.
  • Mark any present parts as thought for submitted tasks.

Tests:

  • Added unit test in tests/unittests/agents/test_remote_a2a_agent.py covering the empty-parts case.
  • Local test run: pytest tests/unittests/agents/test_remote_a2a_agent.py — 70 passed, 81 warnings.

Note: I attempted to request reviewers but got a permissions error when requesting reviewers on the upstream repo. If you want reviewers added, tell me their GitHub handles and whether to: 1) add them as requested reviewers (may fail if repo permissions prevent it), or 2) mention them in a follow-up PR comment (I can do that now).

saurabhhhcodes avatar Dec 02 '25 09:12 saurabhhhcodes