# Codex CLI resume session: codex resume, --last and fork

> Resume a Codex CLI session with codex resume, --last or a session ID. Where Codex keeps sessions, what comes back, and why one is missing from the list.

Source: https://shuriken.sh/guides/codex-resume-session

Run codex resume to pick a past session from a list, codex resume --last to reopen the most recent one from this folder, or codex resume followed by a session ID or name. Add --all to see sessions started in other folders.

[Guides](https://shuriken.sh/guides) By Shuriken Updated 24 November 2026 4 min read

**Contents**

To resume a Codex CLI session, run codex resume and pick one from the list, or codex resume --last to reopen the most recent session from the folder you're in. codex resume <SESSION_ID> takes a session's ID or name directly. Add --all to include sessions you started in other folders.

Codex prints the ID when you quit. The exit screen ends with "To continue this session, run:" and codex resume plus the session's UUID, and a session you named also gets "Or run codex resume and select" its name ([exit_summary.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/app/exit_summary.rs)). The flags below are from OpenAI's [command reference](https://learn.chatgpt.com/docs/developer-commands?surface=cli) and Codex's source, read on 24 October 2026.

## How to resume a Codex CLI session #

| Command | What it does |
| --- | --- |
| codex resume | Opens the session picker, sessions from this folder |
| codex resume --last | Skips the picker: the most recent session from this folder |
| codex resume --all | Picker with sessions from every folder |
| codex resume --last --all | The most recent session from any folder |
| codex resume <SESSION_ID> | That session, by UUID or name |
| codex resume --include-non-interactive | Also lists codex exec runs |
| /resume | Picks a saved session from inside a running one |

Resume accepts the model and sandbox overrides a new session does: codex resume --last -m <model> -s read-only reopens the latest session on another model in a read-only sandbox (the other -s values are workspace-write and danger-full-access). --worktree is refused here.

### The folder question #

Codex saves the directory each session started in. Resume from a different one and it asks which of the two to use. In config.toml, tui.resume_cwd = "current" always takes the directory you're in and "session" always goes back to the saved one; --cd (-C) on the command line beats both. codex fork asks the same question and reads the same setting. [The config.toml guide](https://shuriken.sh/guides/codex-cli-config-toml) lists the files that setting can live in.

## Fork instead of resume #

codex resume reopens the session's own file and keeps writing to it. A fork starts a new session with a fresh ID from a copy, and the original transcript is left as it was, so the first attempt can still be resumed if the second goes nowhere.

- codex fork opens the picker; codex fork --last forks the most recent session.
- /fork forks the session you're in.
- Press Esc twice with an empty composer to edit your previous message and fork from that point.
- codex fork <SESSION_ID> --worktree forks into a managed worktree. It needs an explicit ID.

## Resume a codex exec run #

Scripted runs are sessions too, and they have their own commands:

bash
codex exec resume --last "Now add tests for the parser"
codex exec resume 7f9c2e1a-… "Fix the failing test"
codex exec fork 7f9c2e1a-… "Try it with a streaming parser instead"

--last picks the most recent non-interactive run in this folder, and --all widens it to any folder. codex exec --ephemeral runs without saving the session to disk, so there's nothing to resume afterwards.

Shuriken runs Claude Code, Codex, Gemini CLI and 64 more agents side by side, with your own sign-ins.

[Download](https://shuriken.sh/download)

## Where Codex keeps sessions #

Config, sign-in, logs and sessions all sit in CODEX_HOME ([OpenAI's list](https://learn.chatgpt.com/docs/config-file/environment-variables)), which is ~/.codex unless you set it. [recorder.rs](https://github.com/openai/codex/blob/main/codex-rs/rollout/src/recorder.rs) writes each session as one JSONL file, in a folder for the day it started by your local clock:

~/.codex/sessions/2026/10/24/rollout-<timestamp>-<session-id>.jsonl

The comments in that file use jq -C . <file> to read one. Archived sessions are listed from ~/.codex/archived_sessions/ instead ([lib.rs](https://github.com/openai/codex/blob/main/codex-rs/rollout/src/lib.rs)).

Resuming reloads the rollout file, and OpenAI says the original history stays intact. history.jsonl is a separate file, and two config.toml settings belong to it rather than to sessions: history.persistence (save-all or none) and history.max_bytes, which drops the oldest entries once the file passes that size.

To tidy up, codex archive hides a session from the picker and keeps its transcript (codex unarchive <SESSION> brings it back). codex delete removes the transcript for good.

## Why a session doesn't come back #

Most "it's gone" cases are one of these:

- Another folder. The picker and --last look at this directory. Add --all.
- It was a codex exec run. Add --include-non-interactive, or use codex exec resume.
- It's archived. Run codex unarchive <SESSION>.
- Another CODEX_HOME. Sessions are stored inside it, so a session started with CODEX_HOME=~/.codex-work isn't listed under the default ~/.codex. People who keep one folder per ChatGPT account meet this often. Linking one sessions folder into every home fixes it ([the loop that does it](https://shuriken.sh/guides/codex-cli-switch-account)).
- It ran with --ephemeral. Nothing was saved.

The Claude Code version of this problem has different answers; see [resuming a Claude Code session](https://shuriken.sh/guides/resume-claude-code-session).

## How Shuriken keeps Codex chats going #

In Shuriken, a Codex chat is a chat in a project. It's saved where it runs and opens from any device you've linked, so there's no ID to copy. Add project › Import from… brings your projects and their past chats in from Codex (and Claude Code). An imported Codex chat opens with its history; its first new turn runs in a fork, so the original session file stays as Codex left it.

Each ChatGPT account you add gets its own CODEX_HOME, and Shuriken links the sessions folder into all of them, so the fourth reason above doesn't apply. When one account reaches its limit, the chat moves to another of your accounts when its current turn ends and keeps its conversation; [Codex usage limit reached](https://shuriken.sh/guides/codex-usage-limit-reached) explains that switch. Use only accounts you own and are entitled to use; providers' terms may not allow sharing a subscription sign-in. [Codex with several ChatGPT accounts](https://shuriken.sh/blog/codex-multiple-chatgpt-accounts) has the setup, and you can [download Shuriken](https://shuriken.sh/download) to try it on your own sessions.

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcodex-resume-session&text=Codex%20CLI%20resume%20session%3A%20codex%20resume%2C%20--last%20and%20fork)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcodex-resume-session)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcodex-resume-session&t=Codex%20CLI%20resume%20session%3A%20codex%20resume%2C%20--last%20and%20fork)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcodex-resume-session&title=Codex%20CLI%20resume%20session%3A%20codex%20resume%2C%20--last%20and%20fork)[E-mail](mailto:?subject=Codex%20CLI%20resume%20session%3A%20codex%20resume%2C%20--last%20and%20fork&body=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcodex-resume-session)

## Sources

- [OpenAI: Codex CLI command reference](https://learn.chatgpt.com/docs/developer-commands?surface=cli) (accessed 24 October 2026)
- [OpenAI: Codex config reference (history, tui.resume_cwd)](https://learn.chatgpt.com/docs/config-file/config-reference) (accessed 24 October 2026)
- [OpenAI: Codex environment variables (CODEX_HOME)](https://learn.chatgpt.com/docs/config-file/environment-variables) (accessed 24 October 2026)
- [openai/codex on GitHub: codex-rs/rollout/src/recorder.rs (where sessions are written)](https://github.com/openai/codex/blob/main/codex-rs/rollout/src/recorder.rs) (accessed 24 October 2026)
- [openai/codex on GitHub: codex-rs/tui/src/app/exit_summary.rs (the resume line on exit)](https://github.com/openai/codex/blob/main/codex-rs/tui/src/app/exit_summary.rs) (accessed 24 October 2026)
- [openai/codex on GitHub: codex-rs/rollout/src/lib.rs (sessions and archived_sessions folders)](https://github.com/openai/codex/blob/main/codex-rs/rollout/src/lib.rs) (accessed 25 October 2026)

## Frequently asked questions

**How do I resume my last Codex session?**

cd into the folder you worked in and run codex resume --last; the picker never opens. codex resume --last --all takes the newest session from any folder, and codex resume with the UUID Codex printed on exit opens that exact one.

**Where does Codex CLI store sessions?**

Under CODEX_HOME, which is ~/.codex by default. Codex's source writes each session as a rollout-….jsonl file in sessions/ in folders by year, month and day.

**Why is my Codex session missing from codex resume?**

Usually it was started in another folder (add --all), it was a codex exec run (add --include-non-interactive), it was archived, or Codex ran with a different CODEX_HOME.

**What is the difference between codex resume and codex fork?**

Resume continues the same session. Fork copies it into a new session with a fresh ID and leaves the original transcript as it was, so you can try another approach.

**Can I resume a codex exec run?**

Yes. codex exec resume --last continues the most recent non-interactive run in this folder, and codex exec resume with a session ID continues that one. Both take a follow-up prompt.

Every coding agent

67 coding agents, one harness.

Run Claude Code, Codex, Gemini CLI and the rest on your own computers, with the sign-ins you already have.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [Harness engineering: what it means, and how we do it: Guide 6 Dec 2026 4 min read Harness engineering is building the rules, checks and tools around a coding agent so it gets work right. Our repo's real harness, with dates and counts.](https://shuriken.sh/guides/harness-engineering)
- [The Codex harness: what it is and what runs on it: Guide 5 Dec 2026 5 min read The Codex harness is the agent loop under every Codex surface. The App Server hands it to apps like the IDE extension as JSON-RPC over stdio.](https://shuriken.sh/guides/codex-harness)
- [Codex CLI approval modes and sandbox, explained: Guide 27 Oct 2026 5 min read Codex CLI approval modes are two settings: the sandbox and the approval policy. Auto pairs workspace-write with on-request; untrusted is retired.](https://shuriken.sh/guides/codex-cli-approval-modes)
- [Codex CLI on Windows: native PowerShell or WSL?: Guide 27 Oct 2026 8 min read Codex CLI runs natively in PowerShell inside its own Windows sandbox. In WSL2 it uses the Linux sandbox, needs bubblewrap and no longer runs on WSL1.](https://shuriken.sh/guides/codex-cli-on-windows)
- [Codex "stream disconnected before completion": fixes: Guide 27 Oct 2026 5 min read Codex shows stream disconnected before completion when OpenAI's streamed reply breaks off. It retries 5 times, then stops the turn. How to find the cause.](https://shuriken.sh/guides/codex-stream-disconnected-before-completion)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
