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 context with 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 compacted that 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:

  1. The model is still working. No status line, just latency.
  2. Compaction is running. The client shows Compacting context with 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.
  3. 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 reported systemError, 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

  1. Is there a Compacting context status 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.
  2. Did the context-limit sentence appear? If Codex ran out of room in the model's context window is showing, the turn is blocked, not merely slow.
  3. Does the same prompt fail instantly every time? Instant, repeated failure points at a terminal error rather than a slow turn.
  4. Did Context automatically compacted repeat 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 context as an error. It is a status line.
  • Do not assume Context automatically compacted means the session recovered. It can appear while the session is still stuck.
  • Do not publish or act on codex resume flags such as --last or --all. This research could not retrieve the resume command’s flags from any page opened, so only the bare codex resume is 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 context status 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 failed console string does not exist in any source read; the real strings are the context-window sentence and the remote compact task prefix.

Sources

Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.

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.