Remote compaction preserves assistant messages and leaves next turn at ~234k input tokens

Resolved 💬 4 comments Opened Mar 11, 2026 by wakamex Closed Jun 29, 2026

What version of Codex CLI is running?

codex-cli 0.112.0 source build from 2bc3e52a91bb88a0e067a95f8f8559f8711d30e6

What subscription do you have?

pro

Which model were you using?

gpt-5.4 started on xhigh switched to medium

What platform is your computer?

Linux 6.17.9-300.fc43.x86_64 x86_64 unknown

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

wezterm 20260205_190134_4bf8878b

What issue are you seeing?

Remote compaction is not materially shrinking context for a long-lived thread. In my case, the next turn after compaction still had about 234k input tokens, so compaction was happening repeatedly without creating meaningful headroom.

What steps can reproduce the bug?

Uploaded thread: 019cd2c3-4681-72b1-96bd-3527fa94df9d

I have a local sanitized testcase and compaction breakdown if more detail is needed, but I’m not attaching the full rollout publicly unless requested.

What is the expected behavior?

Compaction should significantly reduce prompt size and create enough headroom for continued work. It should not leave the next turn still near the context window ceiling.

Additional information

Local analysis of the compacted replacement history for this thread showed:

  • 1384 retained items total
  • 815 retained user messages, contributing about 41k serialized tokens
  • 567 retained assistant messages, contributing about 191k serialized tokens
  • 1 retained compaction item, contributing about 2.4k serialized tokens
  • total replacement history estimated at about 235k tokens
  • next turn after compaction had input_tokens ~= 234254

This seems to be happening on the OpenAI remote-compaction path rather than the local 20k-user-message compaction path.

Possibly relevant code: https://github.com/openai/codex/blob/main/codex-rs/core/src/compact_remote.rs#L187

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗