Codex session stuck: not producing output (context / compaction)
A turn that produces no output is one of three states — the model is still working, compaction is running, or the turn has terminally failed. The client shows which: a 'Compacting context' status line means compaction is running, and the context-limit sentence means the session is blocked.
Start here
Watch for a 'Compacting context' status line with an elapsed timer before deciding the turn has hung.
What you see
A long session stops producing output and you cannot tell whether the model is still thinking, compaction is running, or the turn has died. Depending on which state you are in, you may see one of:
- A status line reading
Compacting contextwith an elapsed timer. - A message:
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying. - A prefixed variant:
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. - A line in the desktop app such as
Context automatically compactedthat keeps appearing while nothing progresses.
The first two are states, not all errors. Compacting context is a status line, not a failure.
What it usually means
A turn that produces no output is one of three states:
- The model is still working. No status line, just latency.
- Compaction is running. The client shows
Compacting contextwith an elapsed timer. A merged pull request added this line so compaction is visible while it makes room; before that change, compaction was silent until it finished, so on older builds silence during compaction is expected, not proof of a hang. - The turn has terminally failed. The client reports the context-limit sentence. When the recovery path itself fails, the same text is prefixed with
Error running remote compact task:. In one report the desktop task status then reportedsystemError, an observable “this is genuinely stuck” signal.
Compaction appearing to succeed is not the same as the session recovering. One reporter saw Context automatically compacted repeat about 48 times in roughly 76 minutes while context stayed flat and the session made no useful progress.
Quick checks
- Is there a
Compacting contextstatus line with a timer? If yes, compaction is running — wait and watch the timer. On older builds the absence of that line during compaction is also normal. - Did the context-limit sentence appear? If
Codex ran out of room in the model's context windowis showing, the turn is blocked, not merely slow. - Does the same prompt fail instantly every time? Instant, repeated failure points at a terminal error rather than a slow turn.
- Did
Context automatically compactedrepeat without progress? Repetition without recovery means compaction succeeded but the session did not.
Fixes, by branch
If compaction is running
Wait and watch the Compacting context timer. The merged pull request describes the feature as showing compaction “as soon as manual or server-driven compaction starts, with an elapsed timer independent of the current turn timer.” Do not intervene while the timer is advancing.
If the context-limit message appeared
The client’s own recovery instruction is to start a new thread or clear earlier history before retrying. In one report, the recovery path itself then failed inside remote compact task with the same error, so the recovery was blocked — if a retry also returns context_window_exceeded, the session is stuck and a new thread is the path forward.
If you want to shed context deliberately
The /compact slash command is documented to exist (its row reads “compact the current chat’s context”). Use it to compress history on purpose. Note the documentation does not state it is available in every client, and it rewrites the conversation’s context, so note where you were before running it.
If the turn is merely slow
No status line and no error means the model may still be working. Give it time before assuming a hang.
What not to do
- Do not delete session files or the configuration directory to “fix” a hang. No source in this research recommends deleting
~/.codex/sessions,~/.codex/archived_sessions,history.jsonl, or the SQLite state DB; one reporter backed these up before touching them. Renaming aside with a backup is the reversible pattern if you ever need it. - Do not treat
Compacting contextas an error. It is a status line. - Do not assume
Context automatically compactedmeans the session recovered. It can appear while the session is still stuck. - Do not publish or act on
codex resumeflags such as--lastor--all. This research could not retrieve the resume command’s flags from any page opened, so only the barecodex resumeis documented.
How to tell it worked
The session resumes producing output, or a new thread starts cleanly. A Compacting context timer that completes and is followed by a reply means compaction finished. A context-limit message that does not return on retry means the block cleared.
If it is still failing
If the context-limit message returns on every retry, or systemError persists, the session is blocked. Include the client version, operating system, the exact message, and whether the failure is instant. A related transport string, idle timeout waiting for SSE, can appear as the tail of a compaction failure; that wording is covered by the codex-stream-disconnected guide and is treated there as a separate problem.
Known limits of this guidance
- Evidence level: reported. The spine rests on a merged first-party pull request (the
Compacting contextstatus line), a documented slash-command page (/compact, read via a mirror), and several independent issue reports describing the failure shapes. - The merged pull request is a description of intent, not a release note; it does not say which version shipped the status line, so do not assume your installed build shows it.
- Every compaction-failure report opened here is on Windows or macOS desktop, or the app. No Linux-only compaction or hang report was opened; do not assume Linux behaves the same.
- No release note was read and nothing here establishes that any of this is fixed. No token count or percentage may be quoted as a general rule — the figures in the reports belong to single reporters.
- A literal
compact failedconsole string does not exist in any source read; the real strings are the context-window sentence and theremote compact taskprefix.
Sources
Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.
Show live context compaction status in the TUI (openai/codex #42319, merged 2026-09-02)
The 'Compacting context' status line with an elapsed timer, that compaction used to be silent until it finished (so silence during compaction on older builds is expected, not proof of a hang), and that an error can replace the status text. This is a merged pull request describing intent; it does not state which version shipped the line.
The exact context-limit sentence and its 'Error running remote compact task:' prefix, that the recovery path itself can fail inside remote compaction with the same error, that the desktop task status reported systemError, and the reporter's own statement that the root cause is not established.
Codex automatic context-compaction failure (openai/codex #40213, closed)
That 'Context automatically compacted' can repeat (~48 times in ~76 minutes) without the session recovering — compaction appearing to succeed is not proof the session recovered. Single reporter, one build; the page states no fix.
The failing sequence 'Error running remote compact task:' -> 'stream disconnected before completion:' -> 'idle timeout waiting for SSE', and the reporter's conclusion that the original WebSocket fault and the remaining remote-compaction failure were separate issues — which is why a compaction failure must not be sent to the stream-disconnected page.
Codex slash commands reference — /compact (developers.openai.com, read via mirror 2026-09-20)
That the /compact slash command exists and is documented ('compact the current chat's context'). The canonical developers.openai.com page was Forbidden this session, so this is a mirror copy; the page does not state /compact is available in every client.
Related guides
How this page is checked
- Evidence level
- Reported - based on public reports, not reproduced here
- Last reviewed
- 2026-09-20
- Content updated
- 2026-09-20
- Full version scope
- Reported on Codex CLI 0.153.4 and Codex desktop builds 26.814.41407 (macOS) and 26.908.40834 (Windows), among others opened. No fix version can be named; the scope of the underlying cause across other versions and platforms is unknown.
- Symptoms indexed
-
- A turn stops producing output and you cannot tell whether the model is still thinking or the client has died
- The client shows 'Compacting context' with an elapsed timer while no reply appears
- A message appears: 'Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.'
- Compaction appears to succeed ('Context automatically compacted') but the session makes no progress
Reviewer note
Spine rests on a merged first-party pull request (the status line), a documented slash-command page (/compact, read via mirror), and several independent issue reports describing the failure shapes. No reproduction was performed here, and the merged PR does not name a shipped version. Treat every branch as something to test, not a known fix.