adk-python
adk-python copied to clipboard
fix(agents): tolerate empty A2A message parts in RemoteA2aAgent
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.pycovering empty-parts TASK_REQUIRED. - Local run:
pytest tests/unittests/agents/test_remote_a2a_agent.py— 70 passed, 81 warnings. - Change: guard against empty
event.content.partsinRemoteA2aAgent._handle_a2a_responseto avoid IndexError.
Testing
- Added unit test:
tests/unittests/agents/test_remote_a2a_agent.pycovering empty-parts TASK_REQUIRED. - Local run:
pytest tests/unittests/agents/test_remote_a2a_agent.py— 70 passed, 81 warnings. - Change: guard against empty
event.content.partsinRemoteA2aAgent._handle_a2a_responseto avoid IndexError.
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!
Summary: Fix IndexError in RemoteA2aAgent when A2A TASK responses have empty parts.
What changed:
- Guard against empty
event.content.partswhen handling TASK_REQUIRED responses. - Mark any present parts as
thoughtfor submitted tasks.
Tests:
- Added unit test in
tests/unittests/agents/test_remote_a2a_agent.pycovering 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).