Skip to content

Preserve document follow up type when merging queued gateway events#16589

Closed
hharry11 wants to merge 1 commit into
NousResearch:mainfrom
hharry11:fix/gateway-document-merge-semantics
Closed

Preserve document follow up type when merging queued gateway events#16589
hharry11 wants to merge 1 commit into
NousResearch:mainfrom
hharry11:fix/gateway-document-merge-semantics

Conversation

@hharry11
Copy link
Copy Markdown
Contributor

Summary

Preserve non-text media semantics when merging queued gateway follow-ups.

Previously, if a busy session queued a text follow-up and then received a document follow-up, the merged pending event could remain typed as TEXT. That caused downstream document-specific handling to be skipped, so the attachment was not treated as a document on the next turn.

Root cause

merge_pending_message_event() only promoted merged events to PHOTO. For other media types, a queued TEXT event could keep its original type even after inheriting document media payloads.

Fix

When merging into an existing queued event:

  • keep the existing PHOTO precedence behavior unchanged
  • if the existing pending event is TEXT and the incoming event is a non-text media type, promote the merged event to the incoming message type

This keeps the fix narrow and avoids broader refactoring of merge precedence.

Testing

Added regression test:

  • tests/gateway/test_session_race_guard.py::test_merge_pending_message_event_promotes_document_followups_over_text

Verified result:

  • 1 passed

@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 27, 2026
@teknium1
Copy link
Copy Markdown
Contributor

teknium1 commented May 1, 2026

Merged via #18215 — your commit was cherry-picked onto current main with authorship preserved in git log. Thanks for the fix!

#18215

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