mirror of
https://github.com/openai/codex.git
synced 2026-05-16 09:12:54 +00:00
Reinject canonical context for model-switch pre-turn compaction
This commit is contained in:
@@ -4681,7 +4681,11 @@ async fn maybe_run_previous_model_inline_compact(
|
||||
sess,
|
||||
&previous_turn_context,
|
||||
AutoCompactCallsite::PreTurnExcludingIncomingUserMessage,
|
||||
TurnContextReinjection::Skip,
|
||||
// Even though incoming turn items are excluded here, this pass can be the only
|
||||
// compaction run before submission. Reinject canonical context so unchanged
|
||||
// model-visible instructions remain present if no follow-up pre-turn compaction
|
||||
// is needed.
|
||||
TurnContextReinjection::ReinjectAboveLastRealUser,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -132,11 +132,20 @@ fn assert_pre_sampling_switch_compaction_requests(
|
||||
!compact_body.contains("<model_switch>"),
|
||||
"pre-sampling compact request should strip trailing model-switch update item"
|
||||
);
|
||||
let first_body = first.to_string();
|
||||
assert!(
|
||||
body_contains_text(&first_body, "<environment_context>"),
|
||||
"first request should include canonical environment context"
|
||||
);
|
||||
let follow_up_body = follow_up.to_string();
|
||||
assert!(
|
||||
follow_up_body.contains("<model_switch>"),
|
||||
"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 preserve canonical environment context after pre-sampling compaction"
|
||||
);
|
||||
}
|
||||
|
||||
async fn assert_compaction_uses_turn_lifecycle_id(codex: &std::sync::Arc<codex_core::CodexThread>) {
|
||||
|
||||
Reference in New Issue
Block a user