Skip to content

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
mainfrom
fix/bot-canonical-chat-adopt-on-dead-pin
Closed

teknium1 wants to merge 1 commit into
mainfrom
fix/bot-canonical-chat-adopt-on-dead-pin

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

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.list returns preferred_session: null, and openBotCanonicalChat's recovery branches relied on last_session / preferred_session for 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 to createCanonicalChat, minting a new intro.

Fix

  • findExistingCanonicalBotChat(name): browse the profile's hidden sessions via session.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.
  • All three mint-new branches in 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

Result
hermes-bots suite 335/335 pass
New adopt tests 3/3 pass; 3/3 fail on reverted plugin (sabotage-checked)
Live E2E over gateway RPC (real profile DB) dead pin → preferred_session=nullsession.list finds hidden Bot Chatsession.resume returns real history (4 msgs), not a new intro

Reproduced 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

Bot chats come back

…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).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) area/sessions Session lifecycle, resume, persistence, history area/profiles Multi-profile isolation, HERMES_HOME scoping sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 20, 2026
@teknium1

Copy link
Copy Markdown
Collaborator Author

Superseded by #90738, which bundles this dead-pin adopt fix together with the ownership-file preservation (#89298) and the GUI-handoff backend reap that fixes the same update-incident end to end. Same adopt commit is included there.

@teknium1 teknium1 closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants