fix(bot-mode): dead chat pin adopts the existing hidden Bot Chat instead of reintroducing the bot - #90729
Closed
teknium1 wants to merge 1 commit into
Closed
fix(bot-mode): dead chat pin adopts the existing hidden Bot Chat instead of reintroducing the bot#90729teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
…hat instead of reintroducing the bot on a new session Symptom (reported live on Windows after an update): opening a bot showed a fresh 'introduce yourself' session and the real forever-chat history looked gone. Root cause: the pinned canonical-chat id can go stale (points at a session id that was never persisted or was rewritten past recovery). On a dead pin, profiles.list returns preferred_session=null, and the recovery branches relied on last_session/preferred_session for an adoptable history — but both are computed from a hidden-EXCLUDING query, and Bot Mode sessions are hidden by design. So the real Bot Chat (intact on disk) was never found and every open minted a new intro. Fix: before minting, findExistingCanonicalBotChat browses the profile's hidden sessions (session.list include_hidden:true — the same view the Sessions submenu uses) and adopts the existing 'Bot Chat'. All three mint-new branches route through adoptOrCreateCanonicalChat; the bot is reintroduced ONLY when there is genuinely no forever-chat to return to. The user's messages were never lost — only unpinned. Verified end-to-end over gateway RPC against a real profile DB: dead pin -> preferred_session=null -> session.list finds the hidden Bot Chat -> session.resume returns the real history (not a new intro). 335/335 plugin tests; new adopt tests fail on reverted plugin (sabotage-checked).
Collaborator
Author
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
Opening a bot no longer reintroduces it on a fresh session when its pinned chat id has gone stale — it adopts the profile's existing (hidden) Bot Chat and its full history instead.
Reported live (Windows, after an update): bots opened to a new "introduce yourself" session and the forever-chat history looked gone; some profiles were left on fresh chats. The messages were never lost — only the pin was.
Root cause
A bot's canonical-chat pin (
ui_meta.hermes-bots.chat) can point at a session id that was never persisted or was rewritten past recovery (a "dead pin"). On a dead pin,profiles.listreturnspreferred_session: null, andopenBotCanonicalChat's recovery branches relied onlast_session/preferred_sessionfor an adoptable history. Both are computed from a hidden-excluding query, and Bot Mode sessions are hidden by design — so the real Bot Chat (intact on disk) was never found, and every open fell through tocreateCanonicalChat, minting a new intro.Fix
findExistingCanonicalBotChat(name): browse the profile's hidden sessions viasession.list { include_hidden: true }(the same view the Bots Sessions submenu uses) and return the existing "Bot Chat" id.adoptOrCreateCanonicalChat(name): adopt that chat (open + re-pin) if present; mint a fresh one only when there is genuinely none.openBotCanonicalChat(no-pin/no-history, bad-pin-resolves-to-non-BotChat, definitively-gone) now route through it. The bot is reintroduced ONLY when there is truly no forever-chat.Validation
preferred_session=null→session.listfinds hiddenBot Chat→session.resumereturns real history (4 msgs), not a new introReproduced the exact user symptom first (dead pin in
profile.yaml, real Bot Chat hidden on disk → old code mints intro), then confirmed the fix resolves to the real chat.Note: the user's damaged profiles are recoverable — their old Bot Chats are hidden+unpinned on disk, and this fix re-adopts them on next open. A one-time pin-repair for already-nulled pins can follow if wanted.
Infographic