Original URL: https://getagenttools.com/blog/codex-resume/

# codex resume: picker, --last, --all, fork, and the sandbox exec resume drops

31 Oct 2026Marek.

- codex
- coding-agents
- agent-ops

`codex resume` reopens a saved Codex CLI session. With no arguments it opens a picker. `--last` skips the picker and takes the newest session from the current folder. `--all` drops the folder filter. `codex fork` copies a session into a new one with a fresh ID. For scripts, `codex exec resume --last` does the job without the TUI.

 

```bash
codex resume                          # picker, current folder only
codex resume --last                   # newest session here, no picker
codex resume --all                    # picker across every folder
codex resume <id-or-name>             # one session by UUID or name
codex fork --last                     # copy the newest session, new ID
codex exec resume --last "next step"  # scripted follow-up
```

  

- **Picker by default.** The help puts it in one line: "picker by default; use --last to continue the most recent".
- **Scoped to the folder.** The picker and `--last` look at the current working directory. `--all` widens them.
- **Exec runs stay out.** Sessions from `codex exec` skip the interactive picker. `--include-non-interactive` brings them in.
- **Fork leaves the original alone.** My source session file had 48 lines before the fork and 48 after.
- **`codex exec resume` drops the sandbox.** A `read-only` session blocked my write. Its scripted resume wrote the file.

 

How Claude Code does this, with six entry points and a lookup across projects, is in my [claude --resume](https://getagenttools.com/blog/claude-resume/) post. This one is the Codex side.

 

## How do I resume a Codex session?

 

Run `codex resume` in the project folder and pick a session from the list. If you know which one you want, pass its UUID or its name. Names come from `/rename`. Inside a running chat, `/resume` opens the same picker. The docs describe it as "Resume a saved chat from your session list."

 

The [CLI reference](https://learn.chatgpt.com/docs/cli/reference) marks `codex resume` as stable: "Continue an interactive session by ID or resume the most recent chat."

 

## What does codex resume --last do?

 

It skips the picker. It opens the newest session from the folder you are in. The docs say "Skip the picker and resume the most recent chat from the current working directory." Codex has no separate `continue` command. `codex resume --last` is the Codex version of `claude --continue`.

 

The catch is for people who mix the TUI with scripts. The interactive `--last` ignores sessions started by `codex exec`. The help for `--include-non-interactive` says it will "Include non-interactive sessions in the resume picker and --last selection." In the source, `codex-rs/tui/src/lib.rs` builds the picker filter from CLI and VS Code sessions. `--include-non-interactive` adds exec and app-server sessions.

 

## How do I resume a session from another directory?

 

Use `codex resume --all`. The help says it "disables cwd filtering and shows CWD column". The picker then lists sessions from every folder.

 

Open a session saved in a different folder and Codex stops to ask. The reference says "If the current working directory differs from the session's saved directory, Codex asks which directory to use." Set `tui.resume_cwd` to `"current"` or `"session"` and the question goes away. An explicit `--cd` (`-C`) wins over that setting.

 

Claude Code went the other way. Its sessions page says you can run `claude --resume <session-id>` "from any directory". It looks the ID up without asking. I prefer the Codex question. A resume in the wrong folder edits the wrong checkout.

 

## How do I resume the last Codex session from a script?

 

With `codex exec resume --last "prompt"`. I tested it on 25 October 2026, on Codex CLI 0.163.0, in an empty scratch folder outside any Git repo:

 

```bash
codex exec -s read-only --skip-git-repo-check \
  "Remember this code word for later: PELICAN-42. Do not run any commands. Reply with the single word OK."
# OK

codex exec resume --last --skip-git-repo-check \
  "What code word did I ask you to remember? Reply with the code word only."
# PELICAN-42
```

 

Both runs printed the same session ID. The whole second command took about four seconds. All the turns went into one session file.

 

The surprise was the sandbox. Run one printed `sandbox: read-only`. The resume printed a different sandbox in its header. A header is not proof, so I ran a write test in a second empty folder. A new `read-only` session tried to create a file. The shell said `operation not permitted` and no file appeared. Then `codex exec resume --last`, without `-s`, asked for `probe.txt`. Same session ID. The file was there, with the word I asked for. In 0.163.0 `codex exec resume --help` has no `--sandbox` flag. The source in `codex-rs/exec/src/lib.rs` explains the switch. On resume it sends the model, the approval policy and the sandbox from the config of the new run. A third resume with `-c 'sandbox_mode="read-only"'` printed `read-only` in its header and still knew the word. I did not test a write on that one.

 

So for unattended resumes I pin the sandbox with `-c` on every call. What each sandbox mode allows is in my [Codex dangerously skip permissions](https://getagenttools.com/blog/codex-dangerously-skip-permissions/) post. The same file shows one more thing. If `--last` finds no session in the folder, exec starts a new session instead of failing. I read that in the code. I did not run it.

 

The full non-interactive picture is in my [codex exec](https://getagenttools.com/blog/codex-exec/) post.

 

## What is codex fork?

 

`codex fork` copies a saved session into a new chat with a new ID. The reference: "Fork a previous interactive session into a new chat, preserving the original transcript." It opens a picker by default. It takes `--last` and `--all`. Inside a chat, `/fork` branches the current one.

 

I tested the script form. `codex exec fork <SESSION_ID> "Which code word do you remember?"` answered PELICAN-42 under a new session ID. The file of the original session did not change. `codex exec fork` needs an ID. Its help has no `--last`.

 

Fork is also the safe way to work on one session from two terminals. The Claude Code docs warn that two resumes without forking "interleave into one transcript". I did not test what Codex does there.

 

`codex resume --worktree` is listed in the help but exits with an error on 0.166.0. To continue a session in a separate checkout, fork it with `--worktree`, as shown in [Codex worktree](https://getagenttools.com/blog/codex-worktree/).

 

## Where does Codex store sessions?

 

In `~/.codex/sessions/YYYY/MM/DD/`, one JSONL file per session, named `rollout-<timestamp>-<session-id>.jsonl`. My test session landed in `~/.codex/sessions/2026/10/25/`. The path is built in `codex-rs/rollout/src/recorder.rs` at tag `rust-v0.163.0`. The docs pages I read do not name the folder. Archived sessions go to a sibling folder, `archived_sessions`.

 

## codex archive vs codex delete

 

`codex archive <SESSION>` hides a session from the picker. The transcript stays. `codex unarchive <SESSION>` brings it back. `codex delete <SESSION>` removes the transcript for good. In a chat, `/archive` and `/delete` act on the current session. I ran none of these. My test session is still there.

 

## How does codex resume compare with claude --resume?

 

| Task | Claude Code | Codex CLI |
| --- | --- | --- |
| Pick from a list | `claude --resume` | `codex resume` |
| Newest session here | `claude --continue` | `codex resume --last` |
| Session from another folder | The ID resolves from anywhere | `--all`, then Codex asks which folder |
| Copy instead of continue | `--fork-session` | `codex fork`, `/fork` |
| Scripted follow-up | `claude -p --resume <id>` | `codex exec resume <id>` or `--last` |

 

Copilot CLI keeps the Claude Code names instead of a subcommand: `copilot --continue` and `copilot --resume`, compared in [Copilot CLI resume](https://getagenttools.com/blog/copilot-cli-resume/).

 

## Frequently asked questions

 

### Is there a codex --resume flag?

 

No. Resume is a subcommand. `codex --help` on 0.163.0 lists `resume` under Commands. No `--resume` among the options.

 

### Why does my codex exec session not show up in codex resume?

 

The interactive picker skips non-interactive sessions. Add `--include-non-interactive`. Or stay in scripts with `codex exec resume`.

 

### Does codex exec resume keep the sandbox?

 

Not in my test. A `read-only` session blocked a write. Its resume without `-s` made the same kind of write. The sandbox came from the config of the new run. The interactive `codex resume` is a different path. The reference says it "accepts model and sandbox overrides". In the source, `codex-rs/tui/src/resume_permissions.rs` says omitted choices let the app server "restore the destination task's saved settings". That suggests the TUI brings the session settings back. I have not tested it.

 

## The verdict

 

I use Codex every day as a worker next to Claude Code. My recommendation from this test: `codex resume --last` in the TUI. In scripts, resume by ID and pin the sandbox with `-c` (my test used `--last`). Fork before an experiment you may want to throw away.

 

Sources, read on 25 October 2026: the Codex [CLI reference](https://learn.chatgpt.com/docs/cli/reference) and [developer commands page](https://learn.chatgpt.com/docs/developer-commands?surface=cli), local `--help` for `codex-cli 0.163.0`, the [openai/codex](https://github.com/openai/codex) repository at tag `rust-v0.163.0`, and the Claude Code [Manage sessions page](https://code.claude.com/docs/en/sessions). The test runs are my own.

Put this into practice

[See the tool list](https://getagenttools.com/tools/)[Train your team](https://getagenttools.com/#training)
