Repository navigation
fix(a2a): keep a later canceled state in task aggregation - #8397
Open
sumedh-aerram wants to merge 5 commits into
Open
sumedh-aerram wants to merge 5 commits into
sumedh-aerram wants to merge 5 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_stateandtask_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/executorgives 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/a2aplustests/unittests/integrations/agent_registry/test_agent_registry.py), Python 3.11:'a2a-sdk>=0.3.4,<0.4', as theunit-test-a2a-v0-3job installs it): 1218 passed, 31 skipped.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
Runnerand a mocked model:INVOCATION_ABORTEDevent that reaches the executor after unresolved failures: the task ends canceled and keeps "Invocation was aborted by client." Before the fix, theabortedbranch cleared this message becausetask_statestill 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 --fileson 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
Truefor 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
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.