Repository navigation
fix(server): let SubscribeToTask follow a task that awaits input - #444
Merged
muscariello merged 3 commits intoNov 2, 2026
Merged
muscariello merged 3 commits into
muscariello merged 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
muscariello
force-pushed
the
stack/05-subscribe-interrupted-task
branch
from
November 2, 2026 12:02
7925906 to
479b701
Compare
`subscribe_to_task` resubscribed only to a task whose execution was still registered. An execution that ends in an interrupted state (INPUT_REQUIRED, AUTH_REQUIRED) is unregistered as soon as the executor returns, and the task-store fallback turned only a terminal stored task into UnsupportedOperationError, so a stored task that waits for input was reported as TaskNotFoundError. A2A §3.1.6 allows subscribing to any non-terminal task, and the stream must open with the task as it stands. A subscription that finds no registered execution is now registered with the execution manager, under its lock and before the store is read, so an execution that registers from then on attaches it: `start` subscribes every waiter before the executor runs, so none of that turn's events is missed, and from there the stream is an ordinary resubscription. The stream opens with the stored task and ends where the execution it attached to ends. A missing task is still TaskNotFoundError, a terminal one still UnsupportedOperationError, and a waiter dropped first unregisters itself. Tested with handler unit tests (a turn that asks for input and one that completes; two subscribers polled only after the next turn ran; a dropped subscription; the unchanged errors), `just ci` on Linux, and the official TCK against an agent built on the patched crates, where STREAM-SUB-001/002 and STREAM-ORDER-002..004 now pass instead of being skipped. Fixes: #393 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
A subscription to a task between turns waits for the task's next execution. Cancelling such a task runs no execution, so the cancel's events never reached the waiting subscription and its stream stayed open after the task was canceled. CancelTask now hands the task's final snapshot to the subscriptions still waiting, on success and when the executor's cancel fails; a terminal snapshot ends their streams. Subscriptions register before reading the store, so one that read the task before the cancel is waiting by then, and one that reads it later finds it terminal. The waiter stream drops a missing attachment with filter_map instead of an arm no path reaches, and the tests assert whole event sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
CancelTask ended the subscriptions waiting on a task between turns when it succeeded and when the executor returned an error. It did not when applying an event, sending a push notification or reloading the task failed: the task was already canceled in the store, but those subscribers stayed registered. A guard created once the task is canceled releases them however the call returns. Signed-off-by: Luca Muscariello <muscariello@ieee.org>
muscariello
force-pushed
the
stack/05-subscribe-interrupted-task
branch
from
November 2, 2026 14:28
479b701 to
07015ad
Compare
msardara
approved these changes
Nov 2, 2026
Open
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.
Fixes #393. Replaces #395. Stacked on #443: review only the last three commits.
Cause:
subscribe_to_taskonly follows a task whose execution is still registered. An execution that ends inINPUT_REQUIREDorAUTH_REQUIREDis unregistered when the executor returns, so subscribing to a stored task that waits for input returnsTaskNotFoundError, althoughGetTaskreturns it. §3.1.6 allowsSubscribeToTaskon any non-terminal task.Fix:
ExecutionManagerkeeps awaitingregistry of subscriptions that found no execution. The next execution'sstarthands each one its broadcast channel before the executor runs. A subscription that is dropped early removes its own entry. The second commit ends waiting subscriptions when their task is canceled, sinceCancelTaskruns no execution for them. The third releases them on every exit ofCancelTaskonce the task is canceled, also when applying an executor event, sending a push notification or the final reload fails. Errors for missing and terminal tasks are unchanged.Review focus: this adds shared state behind a
std::sync::Mutex(waiting) next to the existingexecutionslock. The lock order and the "never held across an await" claim should be checked by hand.Unproven: the new tests were run locally (fmt, clippy and the workspace tests pass at the top of the stack). The TCK results quoted in #395 (69 passed instead of 64) were not.