Codex CLI guide: resuming a session

Codex resume: how to continue a Codex CLI session

Run codex resume to pick a past session from a list, or codex resume --last to jump straight back into the most recent one. You can also pass a session id or name, resume from a script with codex exec resume, or branch a copy with codex fork. The picker only shows sessions from the folder you are in, which is the usual reason one seems to be missing.

OpenAI

On Codex CLI

Resume runs before every turn

A Codex client re-establishes the thread each time you send a message. Nothing carries over implicitly between turns, so nothing can go stale between them either.

That is how terminal work is picked up

Because the thread is re-read every turn, work you did in the terminal between two browser messages is already there. Claude needs a process restart for the same thing.

It needs the working directory

Resuming takes a thread id and the working directory together. A thread resumed against the wrong directory is not the same session, which is why a moved project can look like lost history.

Long threads get slow

The cost scales with the conversation, so resuming is the slow part of a turn on a thread with a long history. It is worth a much longer timeout than a normal request, and it is the usual explanation for a Codex turn that seems to hang before it starts.

Rollouts resolve by id

The stored rollout is filed by date rather than by project, so a resume is always keyed on the session id. There is no path you can compute from the project directory.

Commands

Every way to resume a Codex session

All of these are in codex-cli 0.163.0:

CommandWhat it does
codex resumeOpens a picker of sessions started in the current directory.
codex resume --allThe same picker across every directory, with a CWD column.
codex resume --lastContinues the most recent session without showing the picker.
codex resume <SESSION_ID>Continues one session by UUID or by session name.
/resumeInside a running Codex TUI, opens the saved-session picker.
codex exec resume --last "..."Continues a session non-interactively, for scripts and CI.
codex forkCopies a past session into a new one and continues the copy.

Every form takes an optional prompt after the id, so you can resume and send the next message in one line:

bash
codex resume --last "now add tests for the parser"

The picker

codex resume: the session picker

Plain codex resume lists your saved sessions and reloads the one you choose with its history intact. Two filters decide what you see:

  • Directory. By default the list only shows sessions whose working directory matches the one you are in. Run it from the project folder, or add --all to drop the filter and get a CWD column so you can tell projects apart.
  • Interactive only. Sessions created by codex exec are left out. Add --include-non-interactive to include them in the picker and in --last.
bash
cd ~/code/my-app && codex resume
codex resume --all
codex resume --all --include-non-interactive

When the folder you are in and the folder the session was saved in differ, Codex has a setting for which one to use, under its preferences for resuming and forking. The picker layout (dense or comfortable rows) is set in the same place.

Last

codex resume --last, and why --continue does not work

codex resume --last skips the picker and continues the newest recorded session. It is the Codex equivalent of what other tools call continue.

There is no --continue flag in Codex. That is Claude Code's spelling (claude --continue), and Codex stops with error: unexpected argument '--continue' found whether you put it after codex or after codex resume. If a script or an old answer tells you to run codex --continue, replace it with codex resume --last.

By id

Resume a specific Codex session by id or name

codex resume takes either a session UUID or a session name. If the argument parses as a UUID, it is treated as one. Names come from the thread title, and you can set your own with /rename inside the TUI, which makes a long running session easy to reach:

bash
codex resume 0199f3c2-5e1a-7b3d-9c40-2a8e1f6b7d15
codex resume "Fix login redirect"

Three ways to find the id when you do not have it:

  • The index. ~/.codex/session_index.jsonl has one line per session with id, thread_name and updated_at. Search it by name: grep -i "login" ~/.codex/session_index.jsonl.
  • Your prompts. ~/.codex/history.jsonl stores each prompt you typed with its session_id, so you can find a session by something you said in it: grep -i "migration" ~/.codex/history.jsonl.
  • The file name. Each rollout file ends in the session UUID: rollout-<time>-<uuid>.jsonl.

codex resume accepts the same options as codex itself, including -m, --sandbox, --ask-for-approval and -C, so you can pick up a session on a different model or with tighter permissions than it started with.

Scripts

codex exec resume for scripts and CI

codex exec is the non-interactive mode, and it has its own resume subcommand. It takes the same --last, --all, id or name, and the prompt can come from stdin with -:

bash
codex exec resume --last "run the test suite again and fix what fails"
codex exec resume 0199f3c2-5e1a-7b3d-9c40-2a8e1f6b7d15 "summarise what changed"
git diff | codex exec resume --last -

Two things trip this up. A run started with codex exec --ephemeral writes no session file, so there is nothing to resume afterwards. And exec sessions are hidden from the interactive picker unless you pass --include-non-interactive.

Fork

codex fork: branch a session instead of continuing it

Resuming appends to the same session. Forking copies it into a new session and leaves the original untouched, which is what you want when you are about to try something you may throw away.

bash
codex fork            # pick a session to fork
codex fork --last     # fork the most recent one
codex fork <SESSION_ID>
codex exec fork <SESSION_ID> "try the other approach"

Inside the TUI, /fork forks the chat you are in and /new starts a fresh chat in the same CLI session.

Missing

Why a Codex session is missing from codex resume

A session that does not appear in the picker is almost always still on disk. Check these in order:

  1. Wrong folder. The picker filters by working directory. Try codex resume --all.
  2. It was an exec run. Add --include-non-interactive.
  3. It was archived. Archive hides a session without deleting it. codex unarchive <id or name> brings it back.
  4. It predates the current storage layout. codex migrate-rollouts reports legacy sessions that the picker cannot see, and codex migrate-rollouts --apply moves them.

The full diagnosis, including compressed .jsonl.zst rollouts, is in Older Codex sessions are missing from resume.

If the session is listed but will not open, and Codex says This thread is open elsewhere. Close it there and retry resume to continue., another Codex process still holds it. Close that one first. See Codex thread already has an active writer.

History

Where Codex history lives

Codex keeps two different histories under $CODEX_HOME (~/.codex by default). history.jsonl is your prompt history, one line per message you typed. The sessions themselves are rollout files in a dated tree under sessions/, which is what codex resume reads. Setting history.persistence = "none" in config.toml stops prompts from being written to history.jsonl.

The exact layout, the index files and why a session path cannot be worked out from the project folder are covered in Where Codex CLI stores sessions.

Other machines

Resuming a Codex session on another machine

Codex has no sync and no export or import command for sessions. A session exists only in the rollout file on the machine that ran it, and it is tied to a working directory path that has to exist where you resume it. Copying rollout files between machines is not a documented workflow, so do not count on a copied file showing up in the picker.

The reliable approach is to keep the session where it is and reach that machine instead: SSH in and run codex resume there, or use a tool that drives the original machine remotely.

Termdeck

Browse and continue any Codex session from a browser

Termdeck lists the Codex sessions in the folders you have added on each connected machine in one sidebar, including the ones you started in a terminal, so you do not need the picker or the session id. Open one and keep typing. It reads and writes the same rollout files, so the next codex resume in your terminal picks up what you did in the browser, and the other way round.

While a local Codex process still holds the thread open, Termdeck shows the chat as controlled by Codex CLI and keeps it read only rather than writing alongside it. You can still watch it live, from any machine or your phone. See Chats and sessions for how the handoff works, and Codex CLI web UI for the overview. The same task on the other engines: resume a Claude Code session and resume a Grok CLI session.

Compare

How each engine picks a conversation back up

FeatureClaude CodeCodex CLIGrok CLI
Resume mechanismA flag on the next runAn explicit resume callSession state re-read per turn
HappensOnce, at process startBefore every turnBefore every turn
Picks up terminal editsAt the next process startYes, every turnYes, every turn
Identified bySession idThread id plus working directorySession id
Cost of resumingCheapCan be slow on a long threadCheap

Termdeck drives all three from one console, so the differences above stop being three separate habits to remember.

FAQ

Codex CLI resuming a session, answered

How do I resume a Codex CLI session?

Run codex resume to choose from the sessions started in your current folder, or codex resume --last to continue the most recent one. Pass a session id or name to open a specific session.

How do I continue my last Codex session?

Run codex resume --last. Codex has no --continue flag, which is the Claude Code spelling, and rejects it as an unexpected argument.

Why does codex resume not show my session?

The picker only lists sessions from the current working directory and leaves out codex exec runs. Try codex resume --all --include-non-interactive. If it is still missing, it may be archived or stored in the legacy layout that codex migrate-rollouts reports.

How do I find a Codex session id?

Search ~/.codex/session_index.jsonl, which lists each session id with its thread name, or ~/.codex/history.jsonl, which records every prompt you typed with its session id. The rollout file name also ends in the id.

Can I resume a codex exec session?

Yes. Use codex exec resume --last or codex exec resume with an id, followed by the next prompt. To see exec runs in the interactive picker, add --include-non-interactive. A run started with --ephemeral saved nothing and cannot be resumed.

What is the difference between codex resume and codex fork?

Resume continues the same session and appends to it. Fork copies the session into a new one and leaves the original unchanged, so you can try something without losing the version you had.

Can I change the model when resuming a Codex session?

Yes. codex resume accepts the same options as codex, so codex resume --last -m with another model id, or a different --sandbox, applies to the resumed session. Inside the TUI, /model switches it too.