#10605: fix(auto-reply): drain followup queue on error paths + prevent announce bypass
agents
stale
Cluster:
Agent Messaging Enhancements
## Summary
Fixes #5951, Fixes #9278. Two changes to prevent user messages from getting stuck in the followup queue:
### Fix 1: Drain followup queue on error paths (agent-runner.ts)
Added `scheduleFollowupDrain(queueKey, runFollowupTurn)` to the `finally` block of `runReplyAgent`. This ensures queued messages drain even when the run throws before reaching `finalizeWithFollowup`. Safe as a no-op when the queue is empty or already draining.
### Fix 2: Announce respects pending user messages (subagent-announce.ts)
Before the direct `callGateway("agent")` fallback, check `getFollowupQueueDepth(canonicalKey) > 0`. If pending user messages exist, enqueue the announce instead of sending directly -- closing the timing gap between `clearActiveEmbeddedRun` and `scheduleFollowupDrain`.
## Verification
- `pnpm tsgo` passes clean
- Both guards are no-ops on the happy path
Most Similar PRs
#21887: fix: drop stale announce-queue items after 5-minute TTL
by John-Rood · 2026-02-20
68.5%
#3045: [AI-Assisted] fix: preserve pending tasks when subagent completes
by sid1943 · 2026-01-28
66.7%
#23229: fix(subagent-announce): gate queued delivery on channel deliverabil...
by mcinteerj · 2026-02-22
66.0%
#18468: fix(agents): prevent infinite retry loops in sub-agent completion a...
by BinHPdev · 2026-02-16
65.5%
#20490: fix(queue): partition followup routing safety (rebased on latest main)
by Jackten · 2026-02-19
65.2%
#8205: fix: flush followup messages incrementally
by hanxiao · 2026-02-03
64.8%
#22982: fix: prevent stale threadId from routing subagent announces to wron...
by unboxed-ai · 2026-02-21
64.7%
#19243: fix(announce-queue): cap per-item send retries to prevent infinite ...
by taw0002 · 2026-02-17
64.5%
#18205: fix (agents): add periodic retry timer for failed subagent announces
by MegaPhoenix92 · 2026-02-16
64.4%
#19636: fix(agents): harden overflow recovery observability + subagent term...
by Jackten · 2026-02-18
64.3%