Repository navigation
fix(a2a): don't emit agent messages with empty parts for action-only events - #8372
Open
08raviyadav wants to merge 2 commits into
Open
08raviyadav wants to merge 2 commits into
08raviyadav wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
With the new A2A executor, an ADK event carrying only
actions(for example the state change from abefore_agent_callback) is converted into aTASK_STATE_WORKINGstatus update whosestatus.messagehas an emptypartslist. The a2a-sdk task manager appends that message totask.history, soGetTaskand theSendMessageresponse return an agent message with no parts. A2A v1.0 marksMessage.partsREQUIRED (§5.7: required arrays MUST contain at least one element). The legacy executor does not produce this message for the same agent.The old branch fired for every content-less event, not just action-carrying ones: a default
EventActions()serializes to{'stateDelta': {}}, so_serialize_value(event.actions) is not Nonewas always true.Solution:
escalateorskip_summarization(the only actions the reader rebuilds from peer metadata) emit a message-lessWORKINGTaskStatusUpdateEventwith the full event metadata on the update's ownmetadatafield — never aMessagewith emptyparts.convert_a2a_status_update_to_eventnow falls back to the update's ownmetadatafor actions and metadata fields when there is no status message. Message metadata keeps precedence when a message exists._add_event_metadatawas refactored to extract a shared_build_event_metadata(event)helper.Two deliberate scope notes: usage-metadata-only events are skipped like legacy, so usage info for content-less events is dropped on the wire;
convert_a2a_task_to_event(task-level) is intentionally untouched.Testing Plan
Unit Tests:
pytest tests/unittests/a2a/converters/test_from_adk.py tests/unittests/a2a/converters/test_to_adk.py tests/unittests/a2a/converters/test_event_round_trip.py: 131 passed. New tests: escalate-only and skip-summarization-only each emit one message-less WORKING update withadk_actionson the update metadata; state-only, artifact-delta-only and bare empty events emit nothing; the reader rebuildsescalatefrom a message-less update and returnsNonefor a state-delta-only one; round-trip tests cover both directions. The previously buggy-behavior test (test_convert_event_to_a2a_events_with_actions) now expects 0 events, andtest_grounding_metadata_round_trip_messagebuilds its message directly instead of relying on the removed empty-parts message.Control run: the new/updated tests fail on unpatched code (8 of 9; the state-only reader test passes on both by design) and pass with the fix.
Full
tests/unittests/a2a/: 994 passed, 22 failed, 17 errors — the 22 failures + 17 errors are pre-existing environment failures (httpxInvalidURL: Invalid port: ':1]'in client-factory tests), identical on unpatched code. Fulltests/unittestsundertox -e py311: 26,008 passed, 539 failed, 17 errors; zero failures in the touched converter tests, and sampled failures elsewhere (model, telemetry, auth, flows) fail identically on unpatched code with the same httpx signature.tox -e py312/py313/py314were not run locally; CI is the gate for those versions.ruff check,pyink --check,isort --checkandmypyare clean on the changed files.Manual End-to-End (E2E) Tests:
Reproduced the issue's exact scenario (EchoAgent +
before_agent_callbackmutating state,to_a2a()withA2aAgentExecutor(force_new_version=True), oneSendMessageand oneSendStreamingMessage):task.historycontained an agent message with 0 parts andadk_actions: {'stateDelta': {'turns': 1.0}}in both modes.echo: hireply is still delivered as a task artifact; the callback still runs.Checklist
InvalidURL) unrelated to this change.Additional context
None.