|
compressor: single-summary invariant — old summaries always fold into the fresh one
partition_messages now strips is_summary messages out of the turn structure before grouping: a summary is already-compressed history, not a user request. Previously its role=user made it a turn head, so midturn compression kept the old summary verbatim beside the fresh one (head kept + new summary added), and adaptive swap resurrected summary turns whose text pattern-matches the importance heuristics. This piled stale summary copies into the context (one session accumulated 6 copies = 120k of 239k chars) and made compression no-op for whole stretches before a lucky pass finally shrank it. Also folds summaries on the early-exit path so two stale summaries consolidate via the meta-summary, and fixes the demotion loop in compress_and_save_session to cover session.context too: after a reload, context-only rows (is_display=False summaries) were absent from session.messages and never demoted, so is_context=True persisted in the DB and the copies survived into the loaded context. |
|---|
|
|
| navi/core/compressor.py |
|---|
| tests/unit/core/test_compressor.py |
|---|
| tests/unit/workers/test_compression_worker.py |
|---|