Skip to content

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

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

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.
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the clear fix and tests. This bug class is now implemented on current main by merged PR #33817, so this PR is safe to close as superseded.

Evidence:

  • gateway/run.py:3731 on origin/main now has _queue_or_replace_pending_event() for Bug: busy_input_mode: queue silently drops messages — single-slot overwrite instead of FIFO #28503. It documents the old single-slot overwrite, preserves photo/media merge semantics, enforces a queue cap, and routes normal text follow-ups through FIFO via self._enqueue_fifo(...) at gateway/run.py:3768.
  • gateway/run.py:7225 routes busy_input_mode == "queue" follow-ups through _queue_or_replace_pending_event(...), so rapid messages no longer overwrite the single pending slot.
  • Regression coverage exists in tests/gateway/test_queue_consumption.py:393, where five rapid text follow-ups are asserted to remain in FIFO order.
  • The implementation landed in commit 4d0f2bd241694e91d1172194f7a0f73d2d585ba6 and was merged by PR fix(gateway): use FIFO queue for busy_input_mode pending messages #33817 as merge commit 4eb89723903072d2af3ff11462a997fcd5de555b.

This is an automated hermes-sweeper review.

@teknium1 teknium1 closed this Jun 15, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 15, 2026
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 sweeper:implemented-on-main Sweeper: behavior already present on current main 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