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(()); }