Skip to content

fix: refresh idle ActiveTask snapshots on reuse - #1189

Open
KirschBluteX wants to merge 3 commits into
a2aproject:mainfrom
KirschBluteX:fix/refresh-reused-active-task
Open

fix: refresh idle ActiveTask snapshots on reuse#1189
KirschBluteX wants to merge 3 commits into
a2aproject:mainfrom
KirschBluteX:fix/refresh-reused-active-task

Conversation

@KirschBluteX

@KirschBluteX KirschBluteX commented Aug 15, 2026

Copy link
Copy Markdown

Summary

  • Refresh a reused ActiveTask snapshot only when an actual new request enters an idle task boundary.
  • Keep active subscriber/streaming references unchanged so artifact append state remains intact.
  • Coordinate refresh, subscriber acquisition, and close under the task lifecycle lock so concurrent reuse cannot refresh or dispose an active stream.

Root cause

ActiveTaskRegistry retained an ActiveTask across input_required interruptions. Its TaskManager therefore reused an old _current_task snapshot even after another server replica persisted newer artifacts, history, and status to the shared TaskStore. The next request could save that stale snapshot and silently overwrite the newer state.

The registry now asks an existing ActiveTask to invalidate its cached task only at a real request boundary while its reference count is idle (<= 1), under the task lifecycle lock. Active subscribers and streaming requests are not refreshed mid-stream, and concurrent close/reuse paths share the same synchronization boundary.

Tests

  • Added a two-registry shared-store regression test covering replica B's artifact/status persistence and replica A's HITL resubmission/history merge.
  • Related ActiveTask, registry, request, streaming, and shutdown tests: 252 passed.
  • Concurrent request-boundary/subscriber/close stress probe: 300 iterations passed.
  • Ruff check/format and ty passed.
  • Full Windows suite: 1,773 passed.

Fixes #1188

@KirschBluteX
KirschBluteX requested a review from a team as a code owner August 15, 2026 05:22
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/agent_execution/active_task.py 95.09% 95.88% 🟢 +0.80%
src/a2a/server/agent_execution/active_task_registry.py 96.61% 95.77% 🔴 -0.84%
src/a2a/server/request_handlers/default_request_handler_v2.py 94.17% 94.07% 🔴 -0.10%
Total 93.00% 93.04% 🟢 +0.04%

Generated by coverage-comment.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant