fix: recover SessionDB flush cursor from persisted prefix#17146
Open
hanzckernel wants to merge 1 commit intoNousResearch:mainfrom
Open
fix: recover SessionDB flush cursor from persisted prefix#17146hanzckernel wants to merge 1 commit intoNousResearch:mainfrom
hanzckernel wants to merge 1 commit intoNousResearch:mainfrom
Conversation
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.
SessionDB flushing now recovers from the persisted message prefix instead of relying only on the runtime
conversation_historycursor. This prevents sessions whose raw JSON contains the full conversation, but whose SQLitemessagestable is empty or only partially written, from appearing as empty threads in the dashboard orhermes sessions export.Changes
SessionDB.count_messages(session_id)so the current number of persisted messages can be read with a lightweight query._flush_messages_to_session_db()to keep the existing in-memory cursor for duplicate prevention, while falling back to the persisted DB prefix when the runtime cursor has advanced past what was actually written.conversation_historyalready points at the end of the message list;Verification
Passed:
python -m pytest tests/test_session_db_flush_cursor.py tests/hermes_state/test_resolve_resume_session_id.py -q -o 'addopts=' python -m py_compile run_agent.py hermes_state.py tests/test_session_db_flush_cursor.py git diff --checkResult:
Notes
~/.hermes/sessions/session_<id>.jsonintostate.dbbefore they will immediately appear in the dashboard/API.