Skip to content

fix(a2a): warn when output_key cannot reach remote session - #6862

Closed
iarjunganesh wants to merge 3 commits into
google:mainfrom
iarjunganesh:fix/a2a-output-key-handoff
Closed

fix(a2a): warn when output_key cannot reach remote session#6862
iarjunganesh wants to merge 3 commits into
google:mainfrom
iarjunganesh:fix/a2a-output-key-handoff

Conversation

@iarjunganesh

Copy link
Copy Markdown

Link to Issue or Description of Change

Problem:

When an LlmAgent with output_key immediately precedes a
RemoteA2aAgent in a SequentialAgent, the generated content crosses A2A but
the associated session-state key does not. Because the event also has content,
the state-only outbound warning proposed in #6859 does not cover this hand-off.

Solution:

Warn at SequentialAgent construction for that specific adjacent ordering.
The check detects an already-loaded RemoteA2aAgent without importing it, so
ordinary SequentialAgent users do not acquire a dependency on the optional
A2A SDK.

Testing Plan

Unit Tests:

  • Added positive coverage for LlmAgent(output_key) immediately followed
    by RemoteA2aAgent.
  • Added negative coverage for reversed ordering, a remote hand-off without
    output_key, and an entirely local hand-off.
  • pytest tests/unittests/agents/test_sequential_agent.py -q
    (10 passed on Python 3.12).
  • Strict mypy passed for sequential_agent.py.
  • pyink, isort, ruff, ADK compliance checks, and codespell passed
    for both changed files.
  • Verified in an isolated Python 3.12 environment without a2a-sdk that
    importing and constructing a local SequentialAgent still works.

Manual End-to-End (E2E) Tests:

Not run. This change is a deterministic construction-time warning and does not
alter execution or transport behavior.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented the optional-dependency-sensitive code.
  • I have added tests that prove the warning and no-warning paths.
  • New and existing tests in the affected unit pass locally.
  • I have manually tested the change end-to-end.
  • This change has no downstream dependencies.

Additional context

This is intentionally separate from #6859: that PR covers state-only outbound
events and state deltas received from a remote peer. This PR covers a
caller-side output_key event that also contains content, so it is neither a
duplicate nor dependent on #6859.

A SequentialAgent can hand an LlmAgent output to a RemoteA2aAgent while the
associated output_key remains only in the caller session. Warn for that
adjacent hand-off without loading the optional A2A dependency.

Related to google#6854
@google-cla

google-cla Bot commented Aug 22, 2026

Copy link
Copy Markdown

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.

@DeanChensj

Copy link
Copy Markdown
Collaborator

Hi @ALDRIN121,

Thank you for putting together this PR and for the detailed description and test coverage.

After reviewing the approach, we've decided not to merge this change into SequentialAgent, for a few key reasons:

  1. SequentialAgent is deprecated: SequentialAgent is deprecated in favor of Workflow, and we want to avoid introducing new domain-specific validations or tight couplings (such as referencing RemoteA2aAgent) into deprecated legacy components.
  2. Boundary concerns belong in the transport layer: The session state boundary across A2A is a general transport property rather than an issue specific to SequentialAgent. It applies equally to Workflow, custom agents, and standalone runs. This is already being addressed centrally at the RemoteA2aAgent converter and documentation layer in fix(a2a) warn when session state is dropped #6859.
  3. Import order dependency: The sys.modules.get reflection check is sensitive to module import order and would silently skip validation if RemoteA2aAgent is imported lazily or aliased.

Given this, we recommend closing this PR in favor of #6859.

On a related note, we'd love to learn more about your use case: is there a specific reason or blocker that prevented you from using Workflow instead of SequentialAgent? (e.g., missing features, ergonomics, or compatibility issues with RemoteA2aAgent in Workflow). Any feedback here would be very helpful for guiding our workflow orchestration improvements.

Thanks again for contributing!

@DeanChensj DeanChensj closed this Aug 24, 2026
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.

2 participants