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
lucvan
added a commit
to lucvan/hermes-agent
that referenced
this pull request
Jun 9, 2026
…sion split Cherry-pick of upstream PR NousResearch#20485 (still open as of this commit). When mid-run compression splits a session, the gateway updates session_store with the new child session_id but does not update the Telegram DM topic_bindings row in SQLite. On the next inbound message in that topic, the binding lookup at _handle_message_with_agent resolves to the stale pre-compression root, reloads the full transcript, and re-triggers preflight compression. Loop. Local log/DB evidence confirmed the pattern: - Session split detected: 20260512_140504_a4dc00f9 -> ... (repeated) - telegram_dm_topic_bindings.thread_id=1613 still pointed at the pre-compression root session even after the child was created. Fix: after entry.session_id is rewritten on split, also call _record_telegram_topic_binding(source, entry) so the binding tracks the new child. Exception-safe -- failure logs but does not abort the turn. Upstream issue: NousResearch#20470 Upstream PR: NousResearch#20485 When the upstream PR merges, this commit will drop cleanly on the next `git rebase upstream/main`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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