compact: snapshot reinjection above last summary

This commit is contained in:
Charles Cunningham
2026-02-15 21:13:40 -08:00
parent 466c689766
commit 5929f058b0
2 changed files with 26 additions and 0 deletions

View File

@@ -1660,6 +1660,22 @@ keep me updated
},
];
assert_eq!(refreshed, expected);
let refreshed_value =
serde_json::to_value(&refreshed).expect("serialize refreshed history");
let Value::Array(refreshed_items) = refreshed_value else {
panic!("expected refreshed history to serialize as array");
};
assert_snapshot!(
"process_compacted_history_reinject_above_last_summary_shapes",
context_snapshot::format_labeled_items_snapshot(
"When compaction output has multiple summary-only user messages and no real user message, canonical context is reinserted above the last summary.",
&[("Refreshed History Layout", refreshed_items.as_slice())],
&ContextSnapshotOptions::default()
.render_mode(ContextSnapshotRenderMode::KindWithTextPrefix { max_chars: 64 }),
)
);
}
#[test]

View File

@@ -0,0 +1,10 @@
---
source: core/src/compact.rs
expression: "context_snapshot::format_labeled_items_snapshot(\"When compaction output has multiple summary-only user messages and no real user message, canonical context is reinserted above the last summary.\",\n&[(\"Refreshed History Layout\", refreshed_items.as_slice())],\n&ContextSnapshotOptions::default().render_mode(ContextSnapshotRenderMode::KindWithTextPrefix\n{ max_chars: 64 }),)"
---
Scenario: When compaction output has multiple summary-only user messages and no real user message, canonical context is reinserted above the last summary.
## Refreshed History Layout
00:message/user:<COMPACTION_SUMMARY>\nolder summary
01:message/developer:fresh permissions
02:message/user:<COMPACTION_SUMMARY>\nlatest summary