You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_persist_active_session_before_close() could pass the same live transcript list as both messages and conversation_history when the CLI exits during an interrupted/in-flight turn. _flush_messages_to_session_db() treats identities present in conversation_history as already durable, so the close safety-net could write zero rows and lose the transcript on terminal close/SIGHUP/SIGTERM.
This is a residual CLI close-path data-loss case after #50004, and mirrors the dashboard/TUI disconnect alias class fixed in #62052.
Changes
Flush the CLI close safety-net through _persist_session(messages) without a conversation_history argument, so marker-based dedup is used.
Keep the existing fallback to self.conversation_history when _session_messages is not a real list.
Add a real SessionDB regression where cli.conversation_history aliases agent._session_messages; before the fix it stores zero rows, after the fix the interrupted transcript survives.
Update mock call-shape tests to enforce the no-history close-path contract.
Closing as duplicate of #64004, which salvages your original contribution with authorship preserved.
Your PR identified the core bug correctly: _persist_active_session_before_close() passes the same live list as both messages and conversation_history, causing _flush_messages_to_session_db() to treat every message as already durable and write zero rows. The fix (drop the conversation_history argument so marker-based dedup is used instead) is the same approach taken in #64004.
#64004 is a wider salvage that also covers resumed-prefix close, close-before-worker staging, multimodal notes, and concurrent direct/normal flush paths — all on top of your original fix. Your commit and authorship are preserved in that PR's commit history.
Credit: @necoweb3 for the original identification and fix in #63274.
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
comp/cliCLI entry point, hermes_cli/, setup wizardP1High — major feature broken, no workaroundsweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetype/bugSomething isn't working
3 participants
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
_persist_active_session_before_close()could pass the same live transcript list as bothmessagesandconversation_historywhen the CLI exits during an interrupted/in-flight turn._flush_messages_to_session_db()treats identities present inconversation_historyas already durable, so the close safety-net could write zero rows and lose the transcript on terminal close/SIGHUP/SIGTERM.This is a residual CLI close-path data-loss case after #50004, and mirrors the dashboard/TUI disconnect alias class fixed in #62052.
Changes
_persist_session(messages)without aconversation_historyargument, so marker-based dedup is used.self.conversation_historywhen_session_messagesis not a real list.SessionDBregression wherecli.conversation_historyaliasesagent._session_messages; before the fix it stores zero rows, after the fix the interrupted transcript survives.Tests