Compaction state is not synchronized between Codex App and CLI, and /compact cannot recover a resumed long thread
What version of Codex CLI is running?
codex-cli 0.141.0
What subscription do you have?
ChatGPT Plus
Which model were you using?
gpt-5.5 xhigh
What platform is your computer?
Microsoft Windows 10 Pro, version 10.0.19045, x64
What terminal emulator and version are you using (if applicable)?
Windows PowerShell 5.1.19041.6456
Codex doctor report
What issue are you seeing?
I have a long-running thread that was originally created and used extensively in the Codex Desktop App.
When I resume the same thread in Codex CLI, the CLI appears to load more of the original conversation history instead of reusing the latest compacted state or summary from the App.
Running /compact in the resumed CLI thread fails with:
Error running remote compact task: Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
This creates a recovery problem: the thread needs compaction in order to continue, but the compaction request itself cannot run because the resumed context is already too large.
The suspected primary issue is that compaction progress or compacted conversation state is not persisted or synchronized consistently between Codex Desktop and Codex CLI.
A secondary issue is that /compact cannot recover a resumed thread after its loaded history has already exceeded the model context window.
What steps can reproduce the bug?
- Create or open a thread in the Codex Desktop App.
- Continue using the same thread for a long time so that it accumulates a large conversation history and may undergo automatic compaction.
- Close or leave the App thread.
- Open Codex CLI in the same project.
- Resume the App-created thread using the CLI resume function.
- Run
/compactin the resumed thread.
- The compact operation fails with:
Error running remote compact task: Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
- Retrying
/compactproduces the same result, so the existing thread cannot be recovered or continued normally.
What is the expected behavior?
Codex Desktop and Codex CLI should use the same canonical compacted state for a shared thread.
When a thread is compacted in one surface, resuming it from another surface should load the latest compacted summary instead of reconstructing or loading the complete pre-compaction history.
If the resumed thread is already near or beyond the context limit, /compact should still provide a recovery path. It should compact the stored history before loading it into the active model context, or provide another safe way to preserve the thread's important context.
The user should not be forced to abandon the thread and manually start a new one because the command intended to reduce context also exceeds the context limit.
Additional information
Codex Desktop version observed: 26.616.5445.0
Starting a new thread avoids the immediate context error, but it loses the accumulated task context and continuity of the existing thread.
This appears related to existing context-management reports, but this report specifically concerns cross-surface behavior: a long thread created in Codex Desktop is resumed in Codex CLI, and the CLI /compact command cannot recover it.
Related issues:
https://github.com/openai/codex/issues/19842
https://github.com/openai/codex/issues/11325
I can provide the affected thread ID, screenshots, and redacted local logs if needed.
8 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I reviewed the three posts above, and I believe there are many discrepancies. The issue I described is very easy to reproduce. If you follow the steps I outlined, you will definitely be able to reproduce it, because I’ve already tested four different threads—ranging from the app to the CLI—and none of them were able to inherit the compression progress from the app, nor could compression be performed via the CLI.
This is a bad situation, as it limits the ability of more users to switch from the app to the CLI in the future.
One acceptance criterion that would make this debuggable: compaction should have its own durable state record, not only an implicit transcript rewrite.
For App <-> CLI resume, I would want to see:
That last point is the important one. Once resume has loaded too much raw history, asking the model to compact the full thread is already too late. The CLI needs a bounded "use latest compact snapshot + tail" path, or at least a clear diagnostic saying it ignored/missed an available compact revision.
---
_Generated with ax._
I have a thread in vscode codex which i have been using for MONTHS. I just keep talking to it and the conversation is giant. The current thread is 2 months old, but i have some that are older.
I have my own codex CLI app, which i also use to talk to this same thread. I have been moving between vscode and this CLI app for months to talk to this thread.
This has also worked perfectly, for months. But today I'm getting the error "Error running remote compact task: Codex ran out of room in the model's context window. Start a new thread or
clear earlier history before retrying".
That has never happened before. This bug is new.
Adding a related datapoint from #30194 before closing that issue as duplicate.
In addition to
/compactfailing when resumed history is already too large, there is a user-visible case where compaction appears to happen but effective context usage does not materially drop. The thread still behaves near-full on the next turn, so compaction does not provide the recovery users expect.This makes cross-surface or resumed recovery especially brittle: the user needs compaction to produce a genuinely smaller active context, or a clear failure state plus a supported fallback such as fresh context attached to the same existing worktree.
Adding a current Linux CLI datapoint. I use Codex as long-lived steward sessions, so this is not just a small UI annoyance for me. It breaks continuity for sessions that are supposed to behave more like ongoing coworkers than one-off chats.
Setup:
codex-cli 0.142.4codex exec, then TUI for a manual fork/backtrack caseWhat happened:
Escto select an earlier user turn, thenEnterto roll back.I expected the rollback to make the active context small enough again. In practice it looks like the visible transcript and the model-visible compact payload are not the same thing. The fork/backtrack path may still carry enough compacted or inherited history that
/compactitself cannot fit.I checked the local artifacts without posting raw transcripts:
So in this case it does not look like a huge file on disk by itself. It looks more like the resumed/forked compact request is still inheriting too much model-visible history.
This feels related to #9601 for the backtrack/rollback part and #24002 for the long-resume remote compact failure. The operational shape is the same as this issue though: once a resumed or forked thread crosses the line, the command meant to reduce context cannot run anymore.
What would help from the user side:
I can share private session/thread ids or more structured diagnostics if maintainers want them.
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.Quick update from my side in case it helps other people with long-lived sessions.
My old sessions started working again after I killed a stale Codex app-server process.
In my case the CLI had already been updated, but
codex app-server --listen unix://was still running from June 20. So the TUI looked updated, while the backend doing compaction was effectively old.What I did:
Then I started Codex again and resumed the old long-running session.
/compact read ...worked, the session continued, and the context dropped back to a usable state.So if you upgraded Codex but old long sessions still fail, check for a stale app-server/backend process before giving up on the session. This may not recover every broken thread, but it did recover mine.