fix(gateway): preserve media dedup after streamed replies (salvage #72321) - #72341
Merged
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 2b17db0 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job1 visual diff. inline evidence upload failed. Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso) |
Contributor
|
Reproduced this regression on a live Slack gateway: the streamed text was delivered, then I independently verified this patch with a RED/GREEN full-handler regression that included both an echoed prior-turn
Local verification: 203 related gateway/media tests passed; blocking ruff, |
This was referenced Jul 27, 2026
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvages PR #72321 by @TheEpTic: every streamed gateway reply crashed with
NameError: name '_history_media_paths' is not definedafter the model request already succeeded — the post-stream MEDIA-delivery branch in_handle_message_with_agentreferenced a local that only exists inside_run_agent_inner(introduced in 83bba79). Users got the generic platform error on ordinary text replies as well as MEDIA-bearing ones.Root cause: cross-function scope leak — the dedup set was bound in a different function's scope than the call site reading it (AST-verified: zero direct-scope assignments of
_history_media_pathsin_handle_message_with_agent).Changes
gateway/run.py: derive the dedup set from the handler's own loaded transcript via_collect_history_media_paths(history)— same semantics as the original dedup contract, no empty-set fallback.tests/gateway/test_42039_duplicate_user_message.py: regression test exercising the realalready_sentbranch, asserting prior-turn MEDIA paths reach_deliver_media_from_response.Validation
already_sent=TrueNameError, generic platform errorNameErrorscripts/run_tests.sh tests/gateway/test_42039_duplicate_user_message.pyTwo independent production confirmations on the original PR thread (Fedora + macOS Telegram gateways) verified both the crash on current main and this fix.
Duplicate cluster: #72228 (@Ieqzya, earliest report — empty-set fallback drops dedup + unrelated desktop files), #72317 (@jorgeblanc9, same one-liner, no test), #72326 (@kylesteele-sudo, valid alternative placement + test). This salvage uses #72321's implementation; @TheEpTic's authorship preserved via cherry-pick.
Infographic