From bf532c99f717818e2de33af203cd00c028ba4b20 Mon Sep 17 00:00:00 2001 From: Rohit Arunachalam Date: Fri, 17 Apr 2026 11:49:47 -0700 Subject: [PATCH] Document pre-sampling prefix context capture --- codex-rs/core/src/session/turn.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 247360aa7e..5644b743e5 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -160,6 +160,11 @@ pub(crate) async fn run_turn( if pre_sampling_compacted && let Some(mut client_session) = prewarmed_client_session.take() { client_session.reset_websocket_session(); } + // This pre-sampling kickoff captures full context before this turn records its + // context diff. If the candidate is later applied, that captured context can + // sit directly before a retained suffix that starts with the same turn's diff. + // This is redundant but intentional: we keep the suffix untouched and rely on + // the normal prefix/current-history match check before applying. maybe_start_prefix_compact( &sess, &turn_context,