From c4b2ba0ba363fa1fabcac6ba720832dc43ca397c Mon Sep 17 00:00:00 2001 From: Cooper Gamble Date: Mon, 9 Mar 2026 17:58:56 +0000 Subject: [PATCH] [codex-core] Address compaction review feedback [ci changed_files] Remove the redundant inline compaction request trace and clarify that streamed server-side compaction rebuilds replacement history on response.completed from the checkpoint snapshot. Co-authored-by: Codex --- codex-rs/core/src/client.rs | 7 ------- codex-rs/core/src/stream_events_utils.rs | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index 853f693a8f..dc31174bdf 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -578,13 +578,6 @@ impl ModelClientSession { .inline_compaction_threshold .map(ApiContextManagement::compaction) .map(|entry| vec![entry]); - if let Some(threshold) = prompt.inline_compaction_threshold { - trace!( - model = %model_info.slug, - compact_threshold = threshold, - "attaching inline server-side compaction to responses request" - ); - } let request = ResponsesApiRequest { model: model_info.slug.clone(), instructions: instructions.clone(), diff --git a/codex-rs/core/src/stream_events_utils.rs b/codex-rs/core/src/stream_events_utils.rs index 8ae516ff9c..de766133c7 100644 --- a/codex-rs/core/src/stream_events_utils.rs +++ b/codex-rs/core/src/stream_events_utils.rs @@ -152,6 +152,9 @@ pub(crate) struct OutputItemResult { } pub(crate) struct PendingServerSideCompactionCheckpoint { + // Snapshot the raw history at the moment the compaction item streamed. We cannot build + // replacement history yet because later same-turn output may still arrive before + // `response.completed`. pub history_at_checkpoint: Vec, pub item: ResponseItem, pub turn_item: TurnItem, @@ -191,6 +194,8 @@ pub(crate) async fn handle_output_item_done( EventMsg::RawResponseItem(RawResponseItemEvent { item: item.clone() }), ) .await; + // Replacement history is derived on `response.completed` from this snapshot plus whatever + // else the model streamed afterward. output.pending_server_side_compaction = Some(PendingServerSideCompactionCheckpoint { history_at_checkpoint: ctx.sess.clone_history().await.raw_items().to_vec(), item,