Skip to content

fix(gateway): busy_input_mode queue uses FIFO instead of single-slot overwrite#28551

Open
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/busy-input-fifo-queue-28503
Open

fix(gateway): busy_input_mode queue uses FIFO instead of single-slot overwrite#28551
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/busy-input-fifo-queue-28503

Conversation

@zccyman

@zccyman zccyman commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

When busy_input_mode: queue is configured, rapid follow-up messages sent while the agent is busy were silently lost — only the last message was preserved because merge_pending_message_event() was overwriting the single pending slot instead of appending to a FIFO queue.

The gateway already has a proper FIFO implementation (_enqueue_fifo with slot + overflow list), but the busy message path was bypassing it.

Root cause

gateway/run.py line 2887:

# Before (bug): replaces slot → loses all intermediate messages
merge_pending_message_event(adapter._pending_messages, session_key, event)

# After (fix): uses FIFO → appends to overflow when slot occupied
self._enqueue_fifo(session_key, event, adapter)

Behavior change

Scenario Before After
User sends msg1, then msg2-5 rapidly Only msg5 preserved msg1 processed, msg2-5 queued in FIFO
Overflow after drain N/A Promotes msg2 to slot for next turn

Changes

  • gateway/run.py — 1-line change
  • tests/gateway/test_busy_input_queue.py — 4 tests

Testing

  • tests/gateway/test_busy_input_queue.py — 4/4 passed
  • tests/gateway/test_steer_command.py — 5/5 passed (regression)
  • Full suite: 5627 passed, 28 failed (pre-existing unrelated failures)

Upstream gap discovered

Issue #14905 (busy_input_mode: queue only works during drain, not normal task execution) has the same root cause and no competing PR. This fix addresses both issues.

Closes #28503

…overwrite

Replace merge_pending_message_event (single-slot replace) with
_enqueue_fifo (slot + overflow list) in _handle_active_session_busy_message
for queue mode. This ensures rapid follow-up messages are preserved in FIFO
order rather than silently losing all but the last.

Fixes NousResearch#28503.
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

2 participants