Skip to content

fix(gateway): preserve full MessageEvent in active interrupt path - #19825

Closed
QuenVix wants to merge 1 commit into
NousResearch:mainfrom
QuenVix:fix/gateway-preserve-interrupt-media-events
Closed

fix(gateway): preserve full MessageEvent in active interrupt path#19825
QuenVix wants to merge 1 commit into
NousResearch:mainfrom
QuenVix:fix/gateway-preserve-interrupt-media-events

Conversation

@QuenVix

@QuenVix QuenVix commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This fixes a gateway reliability bug in the active-session interrupt path.

When a user sent a follow-up message during an active run, the priority interrupt branch in GatewayRunner._handle_message() stored only event.text in the runner-local pending queue. That worked for plain text, but it dropped the full MessageEvent for media follow-ups such as voice, audio, or documents.

As a result, caption-less or media-only follow-ups could lose their attachment metadata before the next-turn drain, so the queued follow-up no longer re-entered the normal media/STT/document preprocessing path.

What changed

  • Queue the full follow-up MessageEvent into adapter._pending_messages in the priority interrupt path.
  • Preserve existing text-merge behavior for text follow-ups.
  • Keep the old runner-local text-only queue only as a fallback when no adapter is available.

Why this is correct

The gateway already treats adapter-level pending queues as the canonical next-turn handoff for rich follow-ups. Other paths already preserve full events there; this patch aligns the priority interrupt branch with the same behavior instead of collapsing the follow-up into plain text.

That means media follow-ups now survive the interrupt boundary with their original metadata intact.

Tests

Added a regression test covering an active-session interrupt with a media-only voice follow-up:

  • test_handle_message_interrupt_mode_preserves_voice_followup_event

Verified with:

  • pytest tests/gateway/test_busy_session_ack.py -q
  • pytest tests/gateway/test_queue_consumption.py -q

Risk

Low. This is a narrow change in one gateway branch and keeps the legacy text-only path only for the no-adapter fallback case.

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

Copy link
Copy Markdown
Contributor

Thanks for the focused gateway reliability report and regression test.

Automated hermes-sweeper review found this is already implemented on current main:

  • gateway/run.py:5473 queues the original MessageEvent into the adapter-backed pending-event flow before interrupt handling.
  • gateway/platforms/base.py:2123 stores the full event, including media metadata, rather than text alone.
  • gateway/run.py:19563-19625 drains that event and handles voice/audio media before starting the follow-up turn.
  • Commit f6736ced8123e4e17bc0bde89b208c0baedbf0c4 removed the runner-local text queue targeted by this PR after confirming it was write-only; adapter pending events are the real delivery path.

The existing tests/gateway/test_queue_consumption.py:82-100 also covers voice-event metadata retention.

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

3 participants