Skip to content

fix: legacy A2A executor finalizes metadata-only responses as completed#5225

Open
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/legacy-a2a-executor-finalization-5188
Open

fix: legacy A2A executor finalizes metadata-only responses as completed#5225
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/legacy-a2a-executor-finalization-5188

Conversation

@giulio-leone
Copy link
Copy Markdown

Summary

Fixes #5188 — three linked bugs in the legacy A2A executor finalization path.

Root cause

The finalization logic in _handle_request (lines 276-318) only emitted state=completed when the aggregated message had non-empty .parts. Otherwise it fell through to an else-branch that echoed the raw aggregator state (working) into the final=True event.

Meanwhile, TaskResultAggregator replaced the accumulated message on every working event instead of concatenating text, and the synthesized Artifact never copied message.metadata.

Symptoms fixed

# Symptom Fix
1 Metadata-only / no-parts responses finalize as final=True, state=working Else-branch resolves working → completed
2 Delta-streamed text only retains last chunk _accumulate_message() concatenates TextPart.text and merges metadata
3 Synthesized artifact drops response metadata Artifact now carries message.metadata

Files changed

File Change
src/google/adk/a2a/executor/a2a_agent_executor.py Terminal-state resolution + artifact metadata propagation
src/google/adk/a2a/executor/task_result_aggregator.py Text accumulation + metadata merging via _accumulate_message()
tests/unittests/a2a/executor/test_a2a_agent_executor.py 3 new regression tests + 5 existing test expectations corrected
tests/unittests/a2a/executor/test_task_result_aggregator.py 3 new regression tests for delta accumulation + metadata merge

Tests

43 tests pass (37 existing + 6 new):

  • test_metadata_only_response_completes — metadata-only → completed
  • test_streamed_text_accumulated_in_final_artifact — concatenated text in artifact
  • test_metadata_propagated_to_synthesized_artifact — message metadata → artifact
  • test_delta_text_accumulation — aggregator concatenates TextPart chunks
  • test_metadata_merged_across_working_events — aggregator merges metadata dicts
  • test_accumulation_with_none_message_is_noop — None message doesn't clear state

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Apr 9, 2026
@giulio-leone giulio-leone force-pushed the fix/legacy-a2a-executor-finalization-5188 branch from a8f63fc to 2c6180c Compare April 9, 2026 02:34
…ed (google#5188)

Three linked bugs in the legacy A2A executor finalization path:

1. Metadata-only/action-only final responses (working state, message
   with no parts) emitted final=True with status=working instead of
   completed.  The else-branch now resolves working → completed.

2. Delta-style streamed text replaced the accumulated message on each
   event instead of concatenating TextPart content.
   TaskResultAggregator._accumulate_message now appends text chunks
   and merges metadata across successive working events.

3. The synthesized final artifact dropped response metadata from the
   accumulated message. Artifact now carries message.metadata.
@giulio-leone giulio-leone force-pushed the fix/legacy-a2a-executor-finalization-5188 branch from 2c6180c to f69b572 Compare April 9, 2026 03:01
@rohityan rohityan self-assigned this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy A2A executor finalizes metadata-only responses as status=working instead of completed

3 participants