-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Problem
During long-running multi-agent worker sessions, the SDK sends premature session.idle events mid-turn (before the worker is actually done). The premature idle recovery correctly detects this via events.jsonl freshness and re-arms, but there's a visible UI gap:
session.idle→CompleteResponsefires →IsProcessing = false→ spinner vanishes- Recovery code checks events.jsonl → logs "still processing after round N" → waits
- ~30-60s later, SDK sends
TurnStartEvent→EVT-REARMfires →IsProcessing = true→ spinner reappears
The gap between steps 1 and 3 makes it look like nothing is happening, confusing users.
Proposed Fix
When DISPATCH-RECOVER detects the worker is still active (events.jsonl fresh), immediately re-arm IsProcessing = true on the UI thread instead of waiting for the next TurnStartEvent. This keeps the spinner on during the gap.
Key location: CopilotService.Organization.cs — the premature idle recovery loop in WaitForSessionIdleAsync / ExecuteWorkerAsync.
Diagnostics Example
19:48:01 [COMPLETE] 'worker-4' CompleteResponse executing (flushedLen=38921)
19:48:01 [DISPATCH-RECOVER] Worker 'worker-4' premature idle detected — waiting...
19:48:37 [DISPATCH-RECOVER] Worker 'worker-4' still processing after round 18 (re-armed again)
19:49:41 [EVT-REARM] 'worker-4' TurnStartEvent arrived after premature session.idle — re-arming
The ~100s gap between COMPLETE and EVT-REARM is when the spinner is invisible.
Safety Notes
Must follow INV-1 (complete state cleanup checklist) when re-arming. The re-arm should set IsProcessing = true and restart the watchdog, matching the existing EVT-REARM pattern in CopilotService.Events.cs.