Codex CLI Stuck or Frozen? Fix It Without Losing Work

Protect any commands and file edits that already completed, identify whether the active turn or saved session is stuck, then resume from verified work instead of starting the task again.

Do this first: open a second terminal in the repository and run git status --short plus git diff --stat. Record the last visible Codex action. Do not discard the working tree or replay the whole prompt while the original process may still be writing.

Which Codex state is stuck?

No response after the prompt

A fresh prompt produces no streaming output or error. Test a tiny request in a new session and check the official status page before treating the repository as the cause.

Working after a command

The shell command may have finished while the agent loop is still waiting. Check the command result, changed files, and running process before repeating it.

Old session stays on Thinking

The saved transcript may be valid but unable to continue from its last turn. Resume it once; if it loops again, fork the session and begin with one read-only verification.

Resume stays on Loading sessions

Official issue reports show that inaccessible historical working directories can block the picker. Run codex doctor and resume by a known session ID when available.

Recover the work in a controlled order.

Freeze the evidence. Capture the branch, changed files, untracked files, recent commits, and the last command that definitely completed.
Separate a slow turn from a dead turn. Wait while output, CPU activity, or file changes continue. If all three stop for an abnormal interval, avoid stacking more prompts onto the same turn.
Run the supported diagnostic. In another terminal, run codex doctor. It checks the local installation, configuration, authentication, runtime, Git, terminal, app server, and thread inventory.
Update before deep surgery. Run codex update and retest a small prompt. Keep the original session and repository state intact.
Resume once, then fork if needed. Use codex resume --last for the latest session in the current repository. If the old turn remains wedged, use codex fork --last to preserve the transcript while continuing in a new branch.

Resume and fork commands.

codex doctor
codex update
codex resume --last
codex resume <SESSION_ID>
codex fork --last

By default, --last follows the current repository. Use the session picker when you need another saved task. A fork keeps the original transcript unchanged, which is useful when the old continuation path repeatedly stalls.

What ShardStitch can recover from Codex.

ShardStitch reads locally persisted Codex session state in read-only mode and combines it with repository evidence: Git diff, changed files, recent commits, local notes, failed checks, and the next verification action. It can create an AGENTS.md-compatible continuation for a fresh Codex session or another supported coding tool.

Recoverable

Persisted conversation messages, completed file changes, repository state, recent commands, decisions, and recorded verification results.

Not recoverable

Model output that never reached the local session record, edits that were never written, and command results that were neither persisted nor left on disk.

Trust boundary

Conversation text explains intent. Git, files, command output, and tests establish what is true now.

Give the recovered session one next action.

Goal:
Files already changed:
Verified completed work:
Exact stuck state:
Attempts that did not work:
Next safe action:
Verification command:

Ask the resumed or forked session to inspect the current diff before editing. That single boundary prevents duplicate changes and makes a stalled session recoverable.

If resume itself is broken.

If codex resume --last hangs, loads the wrong task, or cannot find the old session, do not keep replaying the original prompt. Use the repository as the source of truth and follow the Codex session corrupted recovery path. That page is for resume-specific failures; this page remains the general stuck/frozen guide.

Sources and verification.

FAQ.

What should I do when Codex CLI is stuck or frozen?

Preserve the working tree first. Run codex doctor, update Codex, and then resume or fork the saved session. Do not assume a frozen display means the last command or edit failed.

How do I resume the last Codex session?

Run codex resume --last from the repository. Use a session ID for a specific task, or codex fork --last when the original continuation path is stale.

Can ShardStitch recover a frozen Codex session?

It can recover locally persisted Codex conversation state and combine it with verified project evidence. It cannot recreate output that was never persisted.

Scope note: Codex stalls can come from a single turn, session history, an active command, authentication, connectivity, or the local runtime. Diagnose the boundary before changing session files.