fix(agent): strip _db_persisted on rotation compression assembly (#57491) - #57531
fix(agent): strip _db_persisted on rotation compression assembly (#57491)#57531nankingjing wants to merge 1 commit into
Conversation
…transcript (NousResearch#57491) Shallow messages[i].copy() during context compression propagated the _db_persisted marker from cached gateway incremental flushes into the post-rotation compressed list. _flush_messages_to_session_db then skipped every row when writing to the new child session, so gateway restarts lost the compacted transcript (severe amnesia). Strip the marker in _fresh_compaction_message_copy() and add regression tests for rotation flush + compressor assembly. Fixes NousResearch#57491
Duplicate of #57508 — same file ( |
|
Fixed on #57574 salvaged this PR's fix (cherry-picked with your authorship preserved) and added a structural follow-up: rather than relying only on the two per-site strips, a single terminal sweep ( Thanks for the fix — closing as superseded (your commit is on |
Summary
Rotation compression (
compression.in_place: false) on long-lived cached gateway sessions lost the compacted transcript fromstate.dbafter restart. Root cause:ContextCompressor.compress()assembled the post-rotation message list withmessages[i].copy(), which propagated the_db_persistedmarker stamped by incremental_flush_messages_to_session_dbflushes. The child-session flush then skipped every copied row.agent/context_compressor.py: add_fresh_compaction_message_copy()that strips_db_persistedbefore head/tail assemblytests/agent/test_context_compressor.py: unit regression — assembled compressed list must not carry markerstests/run_agent/test_compression_persistence.py: end-to-end rotation + flush regression with all source messages pre-markedFixes #57491
Scope note
Follow-up to the compression cluster (#50372 marker dedup, #56391 interrupt demotion). This closes the rotation-path amnesia window without changing in-place compaction behavior.
Test plan
pytest tests/agent/test_context_compressor.py::TestCompress::test_compress_strips_db_persisted_from_assembled_messages -qpytest tests/run_agent/test_compression_persistence.py::TestFlushAfterCompression::test_rotation_child_session_flushes_full_compressed_transcript_with_markers -q