Skip to content

fix(a2a): don't drop state and artifact deltas in the legacy converter - #8020

Open
AtulJoshi1206 wants to merge 1 commit into
google:mainfrom
AtulJoshi1206:fix/a2a-legacy-executor-artifacts
Open

AtulJoshi1206 wants to merge 1 commit into
google:mainfrom
AtulJoshi1206:fix/a2a-legacy-executor-artifacts

Conversation

@AtulJoshi1206

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:

The legacy A2A event converter only produces A2A events for an ADK event that has an error or content. An event that has neither but still changes the session converts to nothing. ADK emits that kind of event in a few common places:

  • an agent callback (or plugin) that saves an artifact or sets state and returns None
  • the built-in code executor, which saves a generated image as an artifact on its own event and replaces the image in the response with Saved as artifact: chart.png.

Since nothing is emitted, no after_event interceptor ever sees these events. With include_artifacts_in_a2a_event_interceptor configured, the client gets the "Saved as artifact" text but never the chart, and an artifact saved in after_agent_callback never shows up in the task. The deltas also never reach the client in the event metadata.

The new executor's converter already handles this: dcc485b made it emit a working status update for an event with no parts but with actions. The legacy converter never got the same change, and it's still the default. A2aAgentExecutor uses it unless the client requests the new integration extension, and RemoteA2aAgent defaults to use_legacy=True.

Solution:

  • convert_event_to_a2a_events: when an event has no content and no error but has a state_delta or artifact_delta, emit a working TaskStatusUpdateEvent with the event metadata and no message. I limited it to session deltas instead of "any non-default actions" so checkpoint-only events (end_of_agent, agent_state) don't start showing up in the legacy stream.
  • TaskResultAggregator: a working update replaced the recorded result even when it had no message. With the converter change, an after_agent_callback that saves a file after the final answer would wipe the answer, and the final result artifact wouldn't be published. A working update without a message now leaves the result alone.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

test_artifact_saved_by_agent_callback_is_published runs a real Runner through A2aAgentExecutor.execute on both executor versions, with the interceptor enabled. The runner has an LlmAgent whose after_agent_callback saves report.txt, plus an InMemoryArtifactService. The test checks that both the artifact and the answer are published.

  • On main, the legacy case fails with assert 'quarterly numbers' in ['Report is ready.'].
  • With only the converter change, it fails the other way ('Report is ready.' in ['quarterly numbers']). That's why the aggregator change is needed.

The converter and aggregator changes each have their own unit test too.

tests/unittests/a2a, a2a-sdk 1.3.0:   1012 passed, 57 skipped
tests/unittests/a2a, a2a-sdk 0.3.26:  1040 passed, 29 skipped
new tests against main's source:      4 failed, 2 passed (both SDK versions)

Manual End-to-End (E2E) Tests:

I ran the built-in code executor case through A2aAgentExecutor with the interceptor enabled and a mocked model that returns an inline PNG:

main  legacy: artifact names=['']               (only "Saved as artifact: chart.png.")
main  new:    artifact names=['chart.png', '']
fix   legacy: artifact names=['chart.png', '']

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This is separate from #6777, which maps Event.output into the message. There, an output-only workflow event goes through the message path. This change covers events that only carry deltas, and the two work together.

The legacy event converter only produced A2A events for an ADK event
that has an error or content. An event with neither that still changes
the session converted to nothing. ADK emits exactly that kind of event
when an agent callback saves an artifact or sets state, and when the
built-in code executor saves a generated image. Because no A2A event
was produced, no after_event interceptor ever saw it, so
include_artifacts_in_a2a_event_interceptor never published those
artifacts and the deltas never reached the client in the event
metadata.

The converter used by the new executor has emitted a working status
update for such events since dcc485b. The legacy converter did not,
and it is still what every client gets unless it opts into the new
integration extension (RemoteA2aAgent defaults to use_legacy=True).

Emit a working status update, carrying the event metadata and no
message, when an event has no content and no error but has a state or
artifact delta.

TaskResultAggregator took every working update as the latest result.
A message-less update that arrives after the final answer, which is
what an after_agent_callback that saves a file produces, would clear
the answer, and the final result artifact would not be published. A
working update without a message now leaves the recorded result alone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant