Skip to content

fix(gateway): isolate pending native image paths by session#18202

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-67d7bdc3
May 1, 2026
Merged

fix(gateway): isolate pending native image paths by session#18202
teknium1 merged 2 commits into
mainfrom
hermes/hermes-67d7bdc3

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented May 1, 2026

Salvage of #17002 (@Yukipukii1) onto current main with a small follow-up nit.

Summary

Fixes a cross-session state leak in the gateway's native-image routing path. Between _prepare_inbound_message_text (writes pending paths) and the consume site inside run_conversation there are many awaits; two sessions interleaving on the same GatewayRunner could overwrite or drop each other's pending native-image attachments.

Changes

  • Replace the runner-global _pending_native_image_paths attribute with a per-session_key dict _pending_native_image_paths_by_session.
  • New _consume_pending_native_image_paths(session_key) helper — pops only the current session's buffer.
  • Write and consume both key off session_key; the write site now uses _session_key_for_source to match every other session-keyed call site in gateway/run.py (follow-up commit on top of the contributor's commit — was calling build_session_key directly).
  • New tests/gateway/test_native_image_buffer_isolation.py: interleaved sessions with native images, and a native-image session not being cleared by a parallel plain-text session.

Validation

scripts/run_tests.sh tests/gateway/test_native_image_buffer_isolation.py
2 passed in 1.03s

Closes #17002. Contributor @Yukipukii1 credited via cherry-picked commit (rebase-merge preserves authorship).

Yukipukii1 and others added 2 commits April 30, 2026 20:24
Minor follow-up to the native-image-buffer isolation fix. The write site
in _prepare_inbound_message_text was calling build_session_key directly,
while every other call site in gateway/run.py uses the _session_key_for_source
helper — which consults session_store._generate_session_key first and falls
back to build_session_key. Keeping the write key and consume key on the
same helper prevents key drift if the session store ever overrides the
default keying behavior.
@teknium1 teknium1 merged commit a178081 into main May 1, 2026
8 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-67d7bdc3 branch May 1, 2026 03:26
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery tool/vision Vision analysis and image generation 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 P1 High — major feature broken, no workaround tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants