Skip to content

fix(gateway): use FIFO queue for busy_input_mode pending messages#33817

Merged
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
sweetcornna:fix/28503-busy-input-fifo
Jun 8, 2026
Merged

fix(gateway): use FIFO queue for busy_input_mode pending messages#33817
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
sweetcornna:fix/28503-busy-input-fifo

Conversation

@sweetcornna

Copy link
Copy Markdown
Contributor

Summary

  • Closes Bug: busy_input_mode: queue silently drops messages — single-slot overwrite instead of FIFO #28503. With busy_input_mode: queue, rapid follow-up text messages were silently overwriting a single pending slot (merge_pending_message_event(..., merge_text=False)), so the agent only saw the most recent message after the current turn finished. Now _queue_or_replace_pending_event routes through the FIFO infrastructure already used by /queue (_enqueue_fifo + the existing _promote_queued_event drain hook), preserving each follow-up as its own turn in arrival order.
  • Photo bursts still merge into the head slot via merge_pending_message_event (album semantics intact); only distinct-turn events fall through to the overflow tail.
  • Added a per-session hard cap of 32 pending follow-ups (_BUSY_QUEUE_MAX_PENDING) so a stuck agent + rapid-fire user cannot grow the overflow unboundedly. There is no obvious precedent in the codebase for a configurable bound here; 32 is far beyond realistic conversational backlog while still trivially small in memory. Items beyond the cap are dropped with a logger.warning (matches the existing pattern used elsewhere for queue caps).
  • Affects every code path that hands off to _queue_or_replace_pending_event: busy_input_mode: queue, the steer-fallback-to-queue path, the subagent demotion path ([Bug]: Sending a message while delegate_task is running kills the subagent — interrupt propagates unconditionally to children #30170), and the draining/restart paths.

Test plan

  • pytest tests/gateway/test_queue_consumption.py — 14 pass (11 existing + 3 new: test_rapid_text_followups_are_queued_in_fifo_order, test_queue_respects_bounded_cap, test_photo_burst_still_merges_in_head_slot).
  • pytest tests/gateway/test_busy_session_ack.py tests/gateway/test_busy_session_auth_bypass.py tests/gateway/test_interrupt_key_match.py tests/gateway/test_text_batching.py tests/gateway/test_telegram_text_batching.py tests/tools/test_interrupt.py tests/cli/test_quick_commands.py — 79 pass (no regressions in adjacent suites).
  • Manual smoke on a real platform adapter (Telegram/WeChat): set display.busy_input_mode: queue, send a slow-running prompt, then fire 5 rapid follow-ups — confirm all 5 are processed sequentially after the current turn ends.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #28551 and #28606 — all fix #28503 (busy_input_mode queue single-slot overwrite). #28551 routes through _enqueue_fifo (1-line); #28606 uses merge_text=True; this PR adds bounded cap (32), photo-burst merge preservation, and broader scoping.

@sweetcornna sweetcornna force-pushed the fix/28503-busy-input-fifo branch from f03eb1a to fec5ca7 Compare June 3, 2026 12:32
@kshitijk4poor kshitijk4poor merged commit 4eb8972 into NousResearch:main Jun 8, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: busy_input_mode: queue silently drops messages — single-slot overwrite instead of FIFO

3 participants