fix: session.idle with stale background-task payload no longer blocks IsProcessing#529
Closed
fix: session.idle with stale background-task payload no longer blocks IsProcessing#529
Conversation
… completion Race condition in IDLE-DEFER: backgroundTasksChanged fires with shells=0 (PolyPilot confirms all shells done) then a session.idle arrives with shells=2 (stale CLI snapshot generated before completions landed). PolyPilot was starting a fresh 60-min zombie clock on the stale payload, keeping IsProcessing=true indefinitely. Fix: capture pre-idle fingerprint/ticks before calling RefreshDeferredBackgroundTaskTracking. If they were null/0 (backgroundTasksChanged already confirmed empty), treat the idle payload as stale and skip the defer. PolyPilot's real-time tracking is ground truth. Observed in the PROMPT session: agents all completed (agents=0), backgroundTasksChanged showed shells=0, but session.idle fired with shells=2 — session stuck in IsProcessing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Changes folded into PR #528. |
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.
Summary
backgroundTasksChanged shells=0fires (PolyPilot confirms all shells done), thensession.idlearrives withshells=2(stale CLI snapshot generated before completions landed). PolyPilot started a fresh 60-min zombie clock from the stale payload, keepingIsProcessing=trueindefinitely.preIdleFingerprint/preIdleTicksbefore callingRefreshDeferredBackgroundTaskTracking. If they were null/0 (meaningbackgroundTasksChangedalready confirmed empty), thesession.idlepayload is stale — skip the defer entirely. PolyPilot's real-timebackgroundTasksChangedtracking is the ground truth over the CLI's snapshot.IsProcessing=trueand no active background tasks must eventually complete. The zombie timeout was being bypassed by the timer reset.Observed failure
PROMPT session — last console.log entries:
PolyPilot's own tracking:
shells=0. CLI idle payload:shells=2. Session stuck.Test plan
SessionIdle_StalePayload_NotDeferredWhenBgTasksAlreadyConfirmedEmpty— structural test verifying the staleness guard is present and wired correctlyBackgroundTasksIdleTestspass (14/16; 2 pre-existing unrelated failures onSessionBackgroundTasksChangedEventstring search)IsProcessingafter next PolyPilot relaunch with this fix