Skip to content

Control over auto-compaction parameters #4106

Description

@Helg1us

Codex CLI 0.40.0 — Auto‑compaction controls

Auto-compaction controls proposal

As a Pro subscriber who depends on long, code-heavy sessions, the hardcoded ~220k auto-compaction threshold is disruptive and should be fully optional (including a hard OFF). It collapses earlier context/code into summaries mid-task and degrades model performance.

Problem

Auto-compaction is an uncontrolled process: once ~220k is reached, the CLI compacts without consent, causing loss of working context and producing worse results than the model could otherwise deliver. This feels chaotic and effectively shortens the usable window.

Minimum (must-have)

  • Add a hard OFF switch that restores previous behavior: no automatic compaction at any token count (only on explicit user action).

Maximum (nice-to-have)

Modes and basic controls

  • off — never compact automatically.
  • on — compact automatically near the limit.
  • manual — prompt/compact only when invoked; allow a threshold to trigger a prompt.
  • smart-auto — adaptive compaction that delays until the end of the current step and preserves pinned blocks; threshold configurable.

Interface examples

CLI:

--autocompact=off|on|manual|auto --autocompact-threshold-tokens=240000

TOML:

[autocompact]
mode = "off" # off|on|manual|auto
threshold_tokens = 240000 # optional per-model override

Expected behavior when OFF

Warn near limits, but never compact unless the user explicitly requests it.

Repro (short)

Codex CLI 0.40.0; grow session to ~220k tokens → auto-compaction fires mid-task → context/code loss and quality drop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contextIssues related to context management (including compaction)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions