fix(gateway): use FIFO queue for busy_input_mode pending messages#33817
Merged
kshitijk4poor merged 2 commits intoJun 8, 2026
Conversation
Collaborator
f03eb1a to
fec5ca7
Compare
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
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_eventroutes through the FIFO infrastructure already used by/queue(_enqueue_fifo+ the existing_promote_queued_eventdrain hook), preserving each follow-up as its own turn in arrival order.merge_pending_message_event(album semantics intact); only distinct-turn events fall through to the overflow tail.32pending 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;32is far beyond realistic conversational backlog while still trivially small in memory. Items beyond the cap are dropped with alogger.warning(matches the existing pattern used elsewhere for queue caps)._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).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.