Skip to content

fix(gateway): preserve document type when merging queued events#18215

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-b7dbdc65
May 1, 2026
Merged

fix(gateway): preserve document type when merging queued events#18215
teknium1 merged 1 commit into
mainfrom
hermes/hermes-b7dbdc65

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented May 1, 2026

Salvage of #16589 by @hharry11 onto current main.

Summary

Cherry-picked on top of current main (branch was 621 commits behind). Clean pick, no conflicts, authorship preserved.

What the fix does

In merge_pending_message_event, when a queued TEXT event absorbs an incoming non-text media event (DOCUMENT, AUDIO, VIDEO), promote the merged event's message_type to the incoming type. Existing PHOTO precedence is untouched.

Why it matters

Session busy → user sends text → user sends a PDF/audio/video. The queued event kept message_type=TEXT even after inheriting the document's media_urls/media_types. Downstream gateway/run.py:5157 gates document content-injection on message_type == DOCUMENT, so the agent received only a bare file path with no context note.

Validation

  • Targeted suite: tests/gateway/test_session_race_guard.py 17/17 pass (includes new regression test)
  • Live E2E against real imports (isolated HERMES_HOME): 8/8 scenarios pass
    • text → doc: promoted to DOCUMENT, text+media preserved, downstream handler fires
    • text → photo: stays PHOTO (precedence unchanged)
    • text → text: burst merge preserved
    • text → audio, text → video: fix generalizes correctly
    • photo → photo album, doc → doc burst, empty → doc: all baseline paths intact

Closes #16589.

@teknium1 teknium1 merged commit 158eb32 into main May 1, 2026
9 of 10 checks passed
@teknium1 teknium1 deleted the hermes/hermes-b7dbdc65 branch May 1, 2026 03:37
@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 1, 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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants