Skip to content

fix(server): prevent failed cancel from overwriting terminal task state - #1405

Open
Iwaniukooo11 wants to merge 1 commit into
a2aproject:mainfrom
Iwaniukooo11:fix/1397-cancel-overwrites-completed-with-failed
Open

Iwaniukooo11 wants to merge 1 commit into
a2aproject:mainfrom
Iwaniukooo11:fix/1397-cancel-overwrites-completed-with-failed

Conversation

@Iwaniukooo11

@Iwaniukooo11 Iwaniukooo11 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

closes #1397

Issue

Cancel event could overwrite a task that was already in terminated state

Change

On producer site: Ensured that task is not in terminal state when enqueueing
On consumer site: If task is in terminal state, drop the current processing event (and .taskdone() on queue)

Test

Added tests that ensure that cancellation events do not overwrite terminal state
Also, re-runned repro provided in issue desc to validate that after the changes, flow works as expected

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/agent_execution/active_task.py 95.84% 96.10% 🟢 +0.26%
src/a2a/server/cluster/database_event_stream.py 97.27% 93.64% 🔴 -3.64%
Total 93.44% 93.41% 🔴 -0.02%

Generated by coverage-comment.yml

@Iwaniukooo11
Iwaniukooo11 marked this pull request as ready for review October 29, 2026 15:12
@Iwaniukooo11
Iwaniukooo11 requested a review from a team as a code owner October 29, 2026 15:12

This branch has not been deployed

No deployments
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.

[Bug]: CancelTask racing the task's own completion overwrites COMPLETED with FAILED

1 participant