Skip to content

[codex] Add internal auto-compaction opt-out#28260

Open
rhan-oai wants to merge 3 commits into
mainfrom
rhan/disable-compaction
Open

[codex] Add internal auto-compaction opt-out#28260
rhan-oai wants to merge 3 commits into
mainfrom
rhan/disable-compaction

Conversation

@rhan-oai

Copy link
Copy Markdown
Collaborator

Summary

  • add a default-on auto_compaction feature flag as an internal escape hatch
  • skip pre-turn, model-switch/hash, and mid-turn automatic compaction when the flag is disabled
  • preserve manual /compact behavior and surface the existing context-window error when the provider runs out of room
  • add integration coverage for disabled pre-turn and mid-turn compaction

Motivation

Long-running SPO optimization rollouts need the option to preserve their full context and fail on context exhaustion instead of entering another compaction window. This deliberately uses the existing feature-flag mechanism rather than adding a dedicated public config or app-server API.

Disable it with:

codex --disable auto_compaction

Testing

  • just test -p codex-features — 51 passed
  • just test -p codex-core auto_compaction_feature_disabled — 2 passed
  • just fix -p codex-core -p codex-features
  • just write-config-schema
  • just test -p codex-core — the new compaction tests passed; the overall local run had 54 unrelated environment failures, primarily missing first-party test binaries and shell-snapshot timeouts

@rhan-oai rhan-oai force-pushed the rhan/disable-compaction branch from 06a856b to 9ddb7a0 Compare June 16, 2026 01:59
@rhan-oai rhan-oai force-pushed the rhan/disable-compaction branch from 9ddb7a0 to df364c3 Compare June 16, 2026 02:01
@rhan-oai rhan-oai marked this pull request as ready for review June 16, 2026 02:02
@rhan-oai rhan-oai requested a review from a team as a code owner June 16, 2026 02:02
@rhan-oai rhan-oai requested a review from jif-oai June 16, 2026 02:02

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-approving but my comment is blocking and needs to be fixed

@@ -299,7 +299,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 token_limit_reached && needs_follow_up {
if turn_context.features.enabled(Feature::AutoCompaction)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still lets new_context drop the whole transcript when token_budget is enabled: that tool is exposed independently, and maybe_start_new_context_window runs above this gate.

Should disabling auto_compaction also hide/reject new_context? Otherwise the SPO escape hatch can discard context instead of reaching the provider error

@@ -4504,6 +4581,44 @@ async fn snapshot_request_shape_pre_turn_compaction_context_window_exceeded() {
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn auto_compaction_feature_disabled_skips_pre_turn_compaction() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a disabled model-switch/comp-hash case too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants