Skip to content

fix(gateway): enhance message handling during agent tasks with queue …#13894

Closed
whitehatjr1001 wants to merge 1 commit into
NousResearch:mainfrom
whitehatjr1001:fix/gateway-queue-interrupt
Closed

fix(gateway): enhance message handling during agent tasks with queue …#13894
whitehatjr1001 wants to merge 1 commit into
NousResearch:mainfrom
whitehatjr1001:fix/gateway-queue-interrupt

Conversation

@whitehatjr1001

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes a bug in the gateway where messages sent while an agent was busy would always interrupt the active task, even when display.busy_input_mode: queue was configured.

The problem was that GatewayRunner._handle_active_session_busy_message unconditionally called agent.interrupt(). This caused long-running tools (like process.wait()) to abort prematurely with an "interrupted" status.

This fix aligns the gateway behavior with the existing logic in cli.py (around line 9138), where interruptions are correctly gated by the busy_input_mode setting.

Related Issue

Fixes #13403

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • gateway/run.py: Updated _handle_active_session_busy_message to respect self._busy_input_mode. It now skips running_agent.interrupt() when in queue mode.
  • gateway/run.py: Updated the user acknowledgment for queue mode to: ⏳ Queued for the next turn... I'll respond once the current task finishes.
  • tests/gateway/test_busy_session_ack.py: Added a new test case test_queue_mode_suppresses_interrupt_and_updates_ack to ensure regression testing for this mode.

How to Test

  1. Set display.busy_input_mode: queue in your config.yaml.
  2. Start the gateway (hermes gateway run).
  3. Send a long task: "Run sleep 10 and tell me when done."
  4. While it's running, send a second message: "What time is it?"
  5. Expected Result: The sleep 10 completes fully (no "interrupted" note), and the second question is answered only after the sleep finishes.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • My PR contains only changes related to this fix
  • I've added tests for my changes
  • I've tested on my platform: macOS

Screenshots / Logs

Successful queue acknowledgment:
⏳ Queued for the next turn (running: terminal). I'll respond once the current task finishes.

@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 Apr 22, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #14762. Cherry-picked your commit onto current main with your authorship preserved in git log (commit 9d147f7). Thanks for the clean diff — picked this over the parallel implementations because the single is_queue_mode flag kept the debounce/status code shared instead of duplicating it. AUTHOR_MAP updated.

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.

busy_input_mode=queue still interrupts process.wait() on new messages

3 participants