openai / openai/codex

Context compaction repeatedly triggers in Ultra during long-running sessions

Open
#40,366 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI context
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

codex-cli 0.149.1

What subscription do you have?

ChatGPT Pro

Which model were you using?

gpt-5.6-sol — Ultra/ultracode effort (almost never observed with xhigh)

What platform is your computer?

macOS 14.5 (23F79), x86_64

What terminal emulator and version are you using (if applicable)?

No response

Codex doctor report

What issue are you seeing?

Codex repeatedly performs context compaction during a long-running session. The problem is much more frequent and severe with Ultra/ultracode effort. After one compaction completes and work continues, another compaction occurs again, and this cycle repeats many times. With xhigh effort, I have almost never encountered this behavior. Each Context compacted entry in the screenshot corresponds to another compaction operation, and the repeated compactions interrupt the normal conversation flow.

What steps can reproduce the bug?
  1. Start Codex CLI 0.149.1 with gpt-5.6-sol using Ultra/ultracode effort.
  2. Open or resume a long-running interactive session.
  3. Continue the conversation until automatic context compaction is triggered.
  4. Continue working after the first compaction completes.
  5. Observe that context compaction is performed again and continues to recur, producing multiple successive Context compacted entries.

Actual result: context compaction itself runs repeatedly during the same session. This behavior is much more frequent and severe with Ultra/ultracode. Under comparable usage with xhigh, I have almost never encountered it.

This is easiest to observe in a long-running session; I do not yet have a short deterministic reproducer.

Image
What is the expected behavior?

After automatic compaction reduces the context, the session should continue normally regardless of effort level. Ultra/ultracode should not cause compaction to repeatedly trigger again unless the context later genuinely crosses the compaction threshold. The behavior should be consistent with xhigh, where I have almost never observed this issue.

Additional information

The issue is much more pronounced with Ultra/ultracode effort; I have almost never encountered it with xhigh. The screenshot captures successive context compaction operations in the same long-running Ultra session. remote_compaction_v2 is enabled.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the automatic context-compaction path in Codex CLI and compare Ultra/ultracode with xhigh while remote_compaction_v2 is enabled. Reproduce in a long-running session, capture successive “Context compacted” entries, and determine why compaction triggers again after the first operation. Done means compaction no longer recurs unless the context genuinely crosses the threshold.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
ai, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.