Show session compaction count in Codex CLI TUI

Open 💬 3 comments Opened Jun 1, 2026 by nicelight
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

Codex CLI

What feature would you like to see?

### Proposal

Show how many times the current Codex CLI session has been compacted.

Example UI:

  • hidden when 0
  • compacted 1x / compacted 2x in the TUI status area after compaction occurs

### Motivation

Context compaction is an important session lifecycle event. When a long-running session has been compacted one
or more times, users may want to know that because it affects debugging, continuity, and the decision whether
to continue the current session or start a fresh one.

This is especially useful for long coding sessions where behavior changes after several compactions and the
user needs a simple signal that the session history has been summarized.

### Proposed behavior

  • Track a compaction_count for the active session.
  • Increment it only after a successful compaction.
  • Preserve it across resume if session metadata already supports that cleanly.
  • Display it unobtrusively in the TUI, preferably hidden at zero.
  • Do not change model prompts, API payloads, or session behavior beyond the visible indicator.

### Prior art

I am running a locally patched Codex CLI with this behavior, and it has been useful as a lightweight context-
health/debugging indicator.

### Acceptance criteria

  • A user can see whether the current session has been compacted.
  • The indicator does not add noise for new/short sessions.
  • The feature works across normal interactive sessions and resumed sessions if feasible.

Additional information

_No response_

View original on GitHub ↗

3 Comments

nicelight · 2 months ago

<img width="817" height="180" alt="Image" src="https://github.com/user-attachments/assets/874ee9fc-798e-4ac3-97df-bf90cbf32b13" />
How it could looks like. It helps me while multisessions runs

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #24366

Powered by Codex Action

Necmttn · 2 months ago

The UI count should come from durable compaction events, not an in-memory counter.

Each successful compaction can record compaction id, source turn range, summary turn id, token/byte estimate before and after, created_at, and status. The TUI badge can display the count, while logs/debug views can explain which context ranges were summarized.

That helps distinguish one bad compact from gradual context drift.

---

_Generated with ax._