[core] inline server-side compaction history rewrite [ci changed_files]

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Cooper Gamble
2026-03-10 16:43:08 +00:00
parent 413b27501d
commit 4427ba8452

View File

@@ -3241,9 +3241,13 @@ impl Session {
item: ResponseItem,
) {
let current_history = self.clone_history().await;
let replacement_history = build_server_side_compaction_replacement_history(
item.clone(),
current_history.raw_items(),
let mut replacement_history = vec![item.clone()];
replacement_history.extend(
current_history
.raw_items()
.iter()
.filter(|history_item| matches!(history_item, ResponseItem::GhostSnapshot { .. }))
.cloned(),
);
let reference_context_item = Some(turn_context.to_turn_context_item());
@@ -5884,20 +5888,6 @@ pub(crate) async fn run_turn(
last_agent_message
}
fn build_server_side_compaction_replacement_history(
compaction_item: ResponseItem,
history_at_compaction: &[ResponseItem],
) -> Vec<ResponseItem> {
let mut replacement_history = vec![compaction_item];
replacement_history.extend(
history_at_compaction
.iter()
.filter(|item| matches!(item, ResponseItem::GhostSnapshot { .. }))
.cloned(),
);
replacement_history
}
fn inline_server_side_compaction_threshold(
sess: &Session,
turn_context: &TurnContext,