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.
1 parent 00c62ee commit 5424c594f568740b62945e5a3f90b1bbd3f6e9e9
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored 1 day ago
Showing 3 changed files
View
navi/core/compressor.py
View
tests/unit/core/test_compressor.py
View
tests/unit/workers/test_compression_worker.py