fix: refresh Telegram DM topic binding after session split (#20470) - #20485
Closed
vominh1919 wants to merge 1 commit into
Closed
fix: refresh Telegram DM topic binding after session split (#20470)#20485vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
…rch#20470) When context compression splits a session, the gateway updates session_store._entries but does not update the corresponding row in telegram_dm_topic_bindings. The next inbound message reads the stale binding, switches back to the pre-compression root session, and re-triggers preflight compression in an infinite loop. Fix by calling _record_telegram_topic_binding() after updating the session store entry, guarded by try/except to handle edge cases.
Collaborator
This was referenced May 14, 2026
This was referenced May 19, 2026
Closed
Contributor
|
This looks implemented on current main by the later merged Telegram topic-binding fix. This is an automated hermes-sweeper review. Evidence:
Thanks for the original fix. The final mainline change covers the same #20470 failure mode and adds the self-heal path for already-stale rows, so this PR can be closed as implemented on main. |
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.
Fixes #20470
Problem
When a session bound to a Telegram DM topic splits during mid-turn context compression, the gateway updates
session_store._entrieswith the new session ID but does not update the corresponding row intelegram_dm_topic_bindings. On the next inbound message in that topic, the gateway reads the stale binding, callsswitch_session()back to the pre-compression root session, reloads its full transcript, fires preflight compression, splits again — repeat forever.Symptom: every message in a Telegram DM topic prints
📦 Preflight compression: ~N tokens >= thresholdeven after the conversation has been compressed multiple times. Each turn pays the full compression latency before any real work begins.Fix
After
session_store._save()updates the in-memory entry and persists it, call_record_telegram_topic_binding(source, entry)to also refresh the SQLite topic-binding row. The call is wrapped intry/exceptto guard against edge cases wherebind_telegram_topicmight raise (e.g. if the new session ID is already linked to a different topic)._record_telegram_topic_bindingalready early-returns whensource.thread_idis falsy, so this is safe across all platform surfaces — only Telegram DM topic bindings are affected.Before vs After