Remote compaction preserves assistant messages and leaves next turn at ~234k input tokens
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
41kserialized tokens - 567 retained assistant messages, contributing about
191kserialized tokens - 1 retained compaction item, contributing about
2.4kserialized tokens - total replacement history estimated at about
235ktokens - 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
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Those other issues have similar symptoms, but they don't point to assistant message retention as the root cause. Happy to provide more details if it helps.
Yes, this likely is the cause of the repeating old messages in a long lived thread bug too.
Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use
/feedbackand open a new bug report.