fix(session): surface silent SessionDB failures that cause session data loss#2939
Open
LucidPaths wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(session): surface silent SessionDB failures that cause session data loss#2939LucidPaths wants to merge 1 commit intoNousResearch:mainfrom
LucidPaths wants to merge 1 commit intoNousResearch:mainfrom
Conversation
…ta loss SessionDB initialization and operation failures were logged at debug level or silently swallowed, causing sessions to never be indexed in the FTS5 database. This made session_search unable to find affected conversations. In practice, ~48% of sessions can be lost without any visible indication. The JSON session files are still written (separate code path), but the SQLite/FTS5 index gets nothing — making session_search return empty results for affected sessions. Changes: - cli.py: Log warnings (not debug) when SessionDB init fails at both __init__ and _start_session entry points - run_agent.py: Log warnings on create_session, append_message, and compression split failures - run_agent.py: Set _session_db = None after create_session failure to fail fast instead of silently dropping every message for the session Root cause: When gateway restarts or DB lock contention occurs during SessionDB() init, the exception is caught and swallowed. The agent continues running normally — JSON session logs are written to disk — but no messages reach the FTS5 index.
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.
Problem
SessionDB initialization and operation failures are logged at
debuglevel or silently swallowed (except Exception: pass), causing sessions to never be indexed in the FTS5 database.session_searchreturns empty results for affected conversations with zero indication anything went wrong.In our deployment, ~48% of sessions (65 out of 135) were missing from the FTS5 index. The JSON session files were written normally (separate code path via
_save_session_log), but the SQLite store got nothing.Root Cause
When the gateway restarts while a CLI session is active (or any DB lock contention during init),
SessionDB()raises an exception that gets caught and swallowed:The agent runs fine — JSON logs are written to disk — but
_session_dbstaysNone, so_flush_messages_to_session_db()short-circuits on every turn and no messages reach FTS5.Changes
WARNING(not debug/pass) when SessionDB init fails at both__init__and_start_sessionentry pointsWARNINGoncreate_session,append_message, and compression split failures_session_db = Noneaftercreate_sessionfailure — fail fast instead of silently dropping every message for the rest of the sessionImpact
Minimal — only changes log levels and adds one
Noneassignment. No behavioral change for the happy path. Users will now see a clear warning when session indexing fails instead of discovering it hours/days later whensession_searchreturns nothing.