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,