Reinject previous-turn context for pre-sampling model-switch compaction

This commit is contained in:
Charles Cunningham
2026-02-18 01:17:13 -08:00
parent 2ede42d319
commit 223eda12d3
5 changed files with 20 additions and 10 deletions

View File

@@ -142,8 +142,8 @@ fn assert_pre_sampling_switch_compaction_requests(
"follow-up request after successful model-switch compaction should include model-switch update item"
);
assert!(
!body_contains_text(&follow_up_body, "<environment_context>"),
"follow-up request should not reinsert canonical environment context after pre-sampling compaction"
body_contains_text(&follow_up_body, "<environment_context>"),
"follow-up request should include canonical environment context from previous-turn context reinjection"
);
}

View File

@@ -1,6 +1,5 @@
---
source: core/tests/suite/compact.rs
assertion_line: 1460
expression: "format_labeled_requests_snapshot(\"Pre-sampling compaction on model switch to a smaller context window: current behavior compacts using prior-turn history only (incoming user message excluded), and the follow-up request carries compacted history plus the new user message.\",\n&[(\"Initial Request (Previous Model)\", &requests[0]),\n(\"Pre-sampling Compaction Request\", &requests[1]),\n(\"Post-Compaction Follow-up Request (Next Model)\", &requests[2]),])"
---
Scenario: Pre-sampling compaction on model switch to a smaller context window: current behavior compacts using prior-turn history only (incoming user message excluded), and the follow-up request carries compacted history plus the new user message.
@@ -22,7 +21,10 @@ Scenario: Pre-sampling compaction on model switch to a smaller context window: c
06:message/user:<SUMMARIZATION_PROMPT>
## Post-Compaction Follow-up Request (Next Model)
00:message/user:before switch
01:message/user:<COMPACTION_SUMMARY>\nPRE_SAMPLING_SUMMARY
02:message/developer:<model_switch>\nThe user was previously using a different model....
03:message/user:after switch
00:message/developer:<PERMISSIONS_INSTRUCTIONS>
01:message/user:<AGENTS_MD>
02:message/user:<ENVIRONMENT_CONTEXT:cwd=<CWD>>
03:message/user:before switch
04:message/user:<COMPACTION_SUMMARY>\nPRE_SAMPLING_SUMMARY
05:message/developer:<model_switch>\nThe user was previously using a different model....
06:message/user:after switch