Skip to content

fix(a2a): keep a later canceled state in task aggregation - #8397

Open
sumedh-aerram wants to merge 5 commits into
google:mainfrom
sumedh-aerram:fix/a2a-task-cancel-priority
Open

sumedh-aerram wants to merge 5 commits into
google:mainfrom
sumedh-aerram:fix/a2a-task-cancel-priority

Conversation

@sumedh-aerram

@sumedh-aerram sumedh-aerram commented Nov 27, 2026 •

Copy link
Copy Markdown

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):

Fixes #8396

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

Problem:
An earlier failure masks a later cancellation in both task_state and task_status_message. A legacy custom converter that emits failed then canceled consequently publishes a failed final status with the stale failure message.

Solution:
Make both result properties honor the existing precedence: canceled > unresolved failed > auth_required > input_required > working. A canceled state remains absorbing for later lower-priority events and failure reconciliation. Its corresponding message wins, including when that message is absent. Abort-marked failed events continue to count as cancellation. Clearing recovered failures still restores the non-canceled non-failure state and message. The executor still maps working to completed when the run ends normally.

Testing Plan

Unit Tests:

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

  • All unit tests pass locally.

  • With the upstream aggregator, tests/unittests/a2a/executor gives 26 failed, 153 passed: 24 aggregator cases, plus the two executor regressions (a failed final status, and a canceled status with no message).

  • python -m pytest -q tests/unittests/a2a/executor (a2a-sdk 1.3.1): 179 passed.

  • The CI A2A set (tests/unittests/a2a plus tests/unittests/integrations/agent_registry/test_agent_registry.py), Python 3.11:

    • a2a-sdk 1.3.1 (default): 1192 passed, 57 skipped.
    • a2a-sdk 0.3.26 ('a2a-sdk>=0.3.4,<0.4', as the unit-test-a2a-v0-3 job installs it): 1218 passed, 31 skipped.
    • The new tests (54) run and pass under both SDKs.
  • Covers both failure/cancellation orders, cancellation alone and followed by lower-priority statuses, present/absent messages, retained/cleared failures, abort-marker cancellation, recovery controls, and the final published status/message from a legacy custom converter without an ADK abort signal.

  • Native abort paths on the legacy executor, with a real in-memory Runner and a mocked model:

    • An INVOCATION_ABORTED event that reaches the executor after unresolved failures: the task ends canceled and keeps "Invocation was aborted by client." Before the fix, the aborted branch cleared this message because task_state still reported failed.
    • executor.cancel() during a slow tool after a sub-agent failure: exactly one final event, canceled, with no stale failure message. The runner is stopped before it yields its sealing abort event, so no cancel message reaches the executor on this path, both before and after the fix.
  • pre-commit run --files on all three changed files (including ADK Compliance Checks): passed.

  • Mypy on the changed source file: no issues. The project normally excludes tests from mypy.

Manual End-to-End (E2E) Tests:

No live transport E2E run. The issue's offline aggregation reproduction now prints True for both event orders. To repeat, run that Python reproduction with this change installed. The executor regression additionally exercises a real in-memory runner with a mocked model and a supported custom converter.

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

Validated with Python 3.11 against a2a-sdk 1.3.1 and 0.3.26. Other Python versions were not run locally. No dependent changes are required.

Give cancellation precedence over recorded failures in the final state and
message, including after failure reconciliation in the legacy executor.

Fixes google#8396
An abort event that reaches the executor after an unresolved failure now
keeps its message in the final canceled status. A cancel() during a run
with an unresolved failure still ends canceled, with no failure message.
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.

A2A task aggregation lets an earlier failure mask cancellation

1 participant