fix(agent): flush messages before compression session rotation (#46567)#46587
fix(agent): flush messages before compression session rotation (#46567)#46587Tranquil-Flow wants to merge 1 commit into
Conversation
✅ Code Review — CleanReviewed the full diff (4 files, +214/-2). This is a well-scoped regression fix for #46567. What was checked:
No issues found. The fix correctly addresses the data loss in intermediate sessions during chained mid-turn compressions. |
bdede42 to
b68a7b1
Compare
|
Closing — the flush-before-rotate fix for #46567 landed via #48584 (salvaged from #47215, authorship preserved). That PR also fixed the sibling #47202 with the same root cause, plus a follow-up commit guarding the /compress unconditional rewrite (#44794/#39704). Your larger variant here is superseded by the merged minimal fix. Thanks for the detailed diagnosis and repro. |
Summary
Fixes #46567 by flushing pending messages to the SQLite session DB before compression closes and rotates away from the current session.
The initial fix added the missing flush before
end_session(...). During Path B review, I tightened the patch so the compression-time flush receivesconversation_history, which preserves the existing_flush_messages_to_session_db(...)contract: already-persisted history rows are skipped, and only the pending mid-turn tail is written to the old session before rotation.What changed
compress_context(...)accepts optionalconversation_historyand passes it through to_flush_messages_to_session_db(...)beforeend_session(...).conversation_historywhen auto-compression fires.end_sessionVerification
_flush_messages_to_session_db(...)before rotation./Users/evinova-self/.hermes/hermes-agent/venv/bin/python3 -m pytest tests/agent/test_compression_flush_before_rotate.py -v -o "addopts=" --tb=short/Users/evinova-self/.hermes/hermes-agent/venv/bin/python3 -m pytest tests/agent/test_compression*.py -v -o "addopts=" --tb=shortdiscord.playeraudioopdeprecation)git rev-list --left-right --count upstream/main...HEAD→0 1Duplicate / competitor check
46567in title/body: nonefix/46567*: nonecompression flush session rotation: noneAuto-published by Moonsong via Path B automated pipeline.