镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(server): resubscribe a paused task from the shared stream - #1327

Open
SashaMIT wants to merge 4 commits into
a2aproject:mainfrom
SashaMIT:fix/paused-task-resubscribe
Open

SashaMIT wants to merge 4 commits into
a2aproject:mainfrom
SashaMIT:fix/paused-task-resubscribe

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1323.

A replica that finished an interrupted turn keeps the task in its registry. SubscribeToTask treated that entry as the live producer, yielded the cached snapshot, and closed. The turn running on another replica was on the shared stream.

The local tap now stays only while this replica holds the request lock. A parked entry follows the snapshot already read from the store and tails the shared stream. A turn that is executing here is still tapped locally. Single-process mode, where there is no shared stream, is unchanged.

The caller is resubscribing to their own task. The store already has the current snapshot. The parked registry entry was the stale one.

Restoring if local is not None makes test_paused_replica_resubscribe_follows_the_shared_stream time out on the parked tap. The in-flight test still receives the local task and leaves the shared stream untapped.

Test plan

  • pytest tests/server/request_handlers/test_default_request_handler_v2.py -k 'paused_replica or in_flight_replica'
  • pytest tests/server/request_handlers/test_default_request_handler_v2.py -k subscribe_to_task
  • Restoring the unguarded local tap times out the paused test

A replica that finished an interrupted turn keeps the task registered. Tapping that entry returned the old snapshot and never saw the turn running elsewhere. The local tap now stays for a turn this replica is executing.
@SashaMIT
SashaMIT requested a review from a team as a code owner October 9, 2026 06:43
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/agent_execution/active_task.py 95.02% 94.84% 🔴 -0.18%
src/a2a/server/cluster/database_event_stream.py 96.94% 92.86% 🔴 -4.08%
src/a2a/server/request_handlers/default_request_handler_v2.py 87.46% 90.09% 🟢 +2.62%
Total 93.14% 93.18% 🟢 +0.04%

Generated by coverage-comment.yml

await self._maybe_cleanup()

def request_in_flight(self) -> bool:
"""True while this replica is executing a turn for the task.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove comment (or at least shorten it to max 1 informative short sentence)

Also, please considering setting _request_log as a property, so we don't need to create a separate method for it (in that case, comment shouldn't be necessary)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. request_in_flight is a property now, so the extra method and the docstring are gone. The handler note is one sentence. Commit a8e2b99.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad - I shouldn't have asked you to drop the docstring entirely. The repo's Ruff config enforces docstring required on public methods, and since request_in_flight is public, the property still needs one

Could you add a single line back, f.e:
"""True while this replica is executing a turn for the task."""

Keeping it to one sentence addresses my original concern too. Sorry for the back-and-forth.

Once that's in, we're good to merge. :)

@Iwaniukooo11 Iwaniukooo11 added status:awaiting response component: server Issues related to frameworks for agent execution, HTTP/event handling, database persistence logic. labels Oct 12, 2026
SashaMIT and others added 3 commits October 12, 2026 21:23
The review asked for one sentence on the handler and a property instead of a method.
Once it is a property, the review said the comment is not needed.

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

component: server Issues related to frameworks for agent execution, HTTP/event handling, database persistence logic. status:awaiting response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cluster mode: SubscribeToTask on a replica holding a paused ActiveTask returns a stale INPUT_REQUIRED snapshot and closes

3 participants