From 98845e484070a1f93fa24842db0e429c7cec9f81 Mon Sep 17 00:00:00 2001 From: sayan-oai Date: Sun, 21 Jun 2026 22:11:42 -0700 Subject: [PATCH] chore: fix merge race (auto-compaction feature access) (#29393) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - read the `AutoCompaction` feature flag through `TurnContext::config` - fix both the mid-turn and pre-sampling compaction checks ## Why #28260 was validated against an older base where `TurnContext` exposed a direct `features` field. It was then merged after that field had moved under `config`, leaving the merge result unable to compile with `E0609` on `turn_context.features`. This restores compilation for Bazel, SDK, and argument-comment-lint jobs that build `codex-core`. Behavior is unchanged: disabling `auto_compaction` still skips automatic compaction. ## Validation - `just fmt` - `CODEX_HOME=/private/tmp/codex-fix-auto-compaction-test-home just test -p codex-core auto_compaction_feature_disabled` — 4 passed - `just test -p codex-core` — `codex-core` compiled; 2,722 passed and 89 unrelated local-environment failures remained because the sandbox could not write the default Codex SQLite/proxy paths and some first-party test binaries were unavailable --- codex-rs/core/src/session/turn.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 2630ba1cc..041da729e 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -334,7 +334,10 @@ pub(crate) async fn run_turn( } // as long as compaction works well in getting us way below the token limit, we shouldn't worry about being in an infinite loop. - if turn_context.features.enabled(Feature::AutoCompaction) + if turn_context + .config + .features + .enabled(Feature::AutoCompaction) && token_limit_reached && needs_follow_up { @@ -848,7 +851,11 @@ async fn run_pre_sampling_compact( turn_context: &Arc, client_session: &mut ModelClientSession, ) -> CodexResult<()> { - if !turn_context.features.enabled(Feature::AutoCompaction) { + if !turn_context + .config + .features + .enabled(Feature::AutoCompaction) + { return Ok(()); }