enable-resume (#3537)

Adding the ability to resume conversations.
we have one verb `resume`. 

Behavior:

`tui`:
`codex resume`: opens session picker
`codex resume --last`: continue last message
`codex resume <session id>`: continue conversation with `session id`

`exec`:
`codex resume --last`: continue last conversation
`codex resume <session id>`: continue conversation with `session id`

Implementation:
- I added a function to find the path in `~/.codex/sessions/` with a
`UUID`. This is helpful in resuming with session id.
- Added the above mentioned flags
- Added lots of testing
This commit is contained in:
Ahmed Ibrahim
2025-09-14 19:33:19 -04:00
committed by GitHub
parent 99e1d33bd1
commit a30e5e40ee
24 changed files with 647 additions and 103 deletions

View File

@@ -12,6 +12,40 @@ Run Codex head-less in pipelines. Example GitHub Action step:
codex exec --full-auto "update CHANGELOG for next release"
```
### Resuming non-interactive sessions
You can resume a previous headless run to continue the same conversation context and append to the same rollout file.
Interactive TUI equivalent:
```shell
codex resume # picker
codex resume --last # most recent
codex resume <SESSION_ID>
```
Compatibility:
- Latest source builds include `codex exec resume` (examples below).
- Current released CLI may not include this yet. If `codex exec --help` shows no `resume`, use the workaround in the next subsection.
```shell
# Resume the most recent recorded session and run with a new prompt (source builds)
codex exec "ship a release draft changelog" resume --last
# Alternatively, pass the prompt via stdin (source builds)
# Note: omit the trailing '-' to avoid it being parsed as a SESSION_ID
echo "ship a release draft changelog" | codex exec resume --last
# Or resume a specific session by id (UUID) (source builds)
codex exec resume 7f9f9a2e-1b3c-4c7a-9b0e-123456789abc "continue the task"
```
Notes:
- When using `--last`, Codex picks the newest recorded session; if none exist, it behaves like starting fresh.
- Resuming appends new events to the existing session file and maintains the same conversation id.
## Tracing / verbose logging
Because Codex is written in Rust, it honors the `RUST_LOG` environment variable to configure its logging behavior.

View File

@@ -10,19 +10,24 @@
Key flags: `--model/-m`, `--ask-for-approval/-a`.
<!--
Resume options:
### Resuming interactive sessions
- `--resume`: open an interactive picker of recent sessions (shows a preview of the first real user message). Conflicts with `--continue`.
- `--continue`: resume the most recent session without showing the picker (falls back to starting fresh if none exist). Conflicts with `--resume`.
- Run `codex resume` to display the session picker UI
- Resume most recent: `codex resume --last`
- Resume by id: `codex resume <SESSION_ID>` (You can get session ids from /status or `~/.codex/sessions/`)
Examples:
```shell
codex --resume
codex --continue
# Open a picker of recent sessions
codex resume
# Resume the most recent session
codex resume --last
# Resume a specific session by id
codex resume 7f9f9a2e-1b3c-4c7a-9b0e-123456789abc
```
-->
### Running with a prompt as input