Skip to content

A2A task aggregation lets an earlier failure mask cancellation #8396

In review

Description

@sumedh-aerram

TaskResultAggregator documents cancellation as higher priority than failure, but a failure followed by cancellation still returns failed and the failure message. Reversing the event order returns canceled. A recorded failure masks the cancellation state and message, including for legacy custom-converter events.

Environment: ADK main (2.15.x), Python 3.11.

Offline reproduction (no model or network calls):

from google.adk.a2a import _compat
from google.adk.a2a.executor.task_result_aggregator import TaskResultAggregator

for states in [
    [_compat.TS_FAILED, _compat.TS_CANCELED],
    [_compat.TS_CANCELED, _compat.TS_FAILED],
]:
    result = TaskResultAggregator()
    for state in states:
        result.process_event(_compat.make_task_status_update_event(
            task_id="task", context_id="context",
            status=_compat.make_task_status(state),
        ))
    print(result.task_state == _compat.TS_CANCELED)

Actual:

False
True

Expected:

True
True

Activity

  1. added
    a2a
    on Nov 30, 2026
  2. surajksharma07 commented on Dec 2, 2026

    @surajksharma07
    Collaborator

    Thanks @sumedh-aerram, I can reproduce this on main (b1566b8, still 2.15.1). It goes back to 2.14.0, where cancel propagation and the separate _failed tracking both landed. The task_state and task_status_message properties check _failed before CANCELED.

    I tried a small workaround locally. Checking CANCELED first in both properties fixes both orders. Recovered failures still go back to the right state and tests/unittests/a2a/executor stays green (124 passed). It looks like the same idea as #8397.

    Could you confirm it holds on your end? Two things would help. One is the native abort path, since executor line 360 currently drops the cancel message there. The other is a run against a2a-sdk 0.3.x, since the PR says that matrix wasn't run.

    Once that's confirmed I'll ask the A2A owners to review #8397.

  3. sumedh-aerram commented on Dec 2, 2026

    @sumedh-aerram
    Author

    Thanks @surajksharma07, confirmed on my end:

    • Same fix. fix(a2a): keep a later canceled state in task aggregation #8397 checks CANCELED before _failed in both task_state and task_status_message, as in your workaround. When recovered failures are dropped, the task still goes back to its non-failure state and message. tests/unittests/a2a/executor: 179 passed.
    • Native abort path. Line 360 only drops a real cancel message when an INVOCATION_ABORTED event reaches the executor after an unresolved failure, because task_state still reported failed. With the fix, the task ends canceled with "Invocation was aborted by client." (new test, which fails on main). With executor.cancel() and the stock Runner, the run is stopped before the sealing abort event is yielded, so no cancel message reaches the executor. The task ends canceled with no stale failure message, both before and after the fix (also covered by a test). No executor change was needed.
    • a2a-sdk 0.3.x. The CI A2A set (tests/unittests/a2a + agent_registry) on Python 3.11 with a2a-sdk 0.3.26: 1218 passed, 31 skipped. With a2a-sdk 1.3.1: 1192 passed, 57 skipped. The new tests pass on both. I've updated the PR description.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

a2a

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions