How to resume Codex non-interactively
Use codex exec resume with a session ID or --last, send a prompt argument or stdin, and understand how --all and ephemeral execution affect automation.
Use codex exec resume <session-id> "prompt" to continue a saved Codex session without the interactive UI. Use --last only when the newest recorded session is the intended one. A prompt of - reads stdin. Add --all when selecting the last session across directories, and --json when a program needs JSONL events.
When to use it
The exec form is designed for scripts and pipelines: it sends one instruction, streams output, and exits. It is distinct from interactive codex resume, which opens the TUI and can show a picker.
Errors you may see
| Message | What it tells you | What to do |
|---|---|---|
| no rollout found for thread id <id> | Codex has no saved session file with that id in the CODEX_HOME it is using. | Check the id. If the session belongs to another account, run with that account's CODEX_HOME. Run codex resume --all to see every session in this home. |
| session <id> is archived. Run `codex unarchive <id>` to unarchive it first. | The session exists but was archived, and Codex will not resume an archived session. | Run codex unarchive with the same id, then resume it. |
| Not inside a trusted directory and --skip-git-repo-check was not specified. | codex exec refuses to run outside a trusted directory, before it looks the session up. | Run from the project's repository, or pass --skip-git-repo-check to codex exec when that is intended. |
| error: unexpected argument '--continue' found | Codex has no --continue flag; that is Claude Code's. | Use codex resume --last interactively, or codex exec resume --last in a script. |
Use it safely
1. Prefer an explicit session
Store the session UUID from the workflow that created it and pass that value on the next run. This avoids coupling automation to whichever human or scheduled task happened to run most recently.
codex exec resume <session-id> "Run the focused test and report the remaining failure."2. Pipe bounded input with a dash
A positional dash tells Codex to read the next instruction from standard input. Review what the producer emits; piping an unrestricted log or diff can overflow context or disclose data the task does not need.
git diff -- src/checkout.py | codex exec resume <session-id> -3. Choose machine-readable output when needed
--json prints JSONL events for a consumer. --output-last-message writes the final response to a file, while --ephemeral runs without persisting new session files. Pick persistence deliberately.
codex exec resume --json --output-last-message result.txt <session-id> "Summarize the verified result."Important distinctions
- The resume subcommand still executes agent tools under its configured approval and sandbox policy; non-interactive does not mean harmless.
- --last normally follows directory filtering. Use --all only when cross-directory newest is truly what the script intends.
- A resumed exec run may be omitted from ordinary interactive pickers unless the picker includes non-interactive sessions.
- A SESSION_ID that is a name matching no thread does not fail: codex-cli 0.146.0 starts a new session and sends the prompt there. In scripts, pass the UUID and check the session id line in the header.
Questions
Does Codex have a --continue flag?
No. In codex-cli 0.146.0, codex --continue fails with “unexpected argument '--continue' found”. The equivalent of Claude Code's --continue is codex resume --last in the interactive UI, or codex exec resume --last in a script.
What does “no rollout found for thread id” mean?
Codex looked for the saved session file (the rollout) for that id and found none in the current CODEX_HOME. The id is wrong, or the session was created under a different CODEX_HOME, such as a second account.
Why did codex exec resume start a new session?
The session argument accepts a UUID or a thread name. If a name matches no thread, codex-cli 0.146.0 does not fail; it starts a new session with a new id and sends your prompt there. Use the UUID in scripts and compare the session id line in the header.
Can I resume an archived Codex session from a script?
Not directly. Codex answers that the session is archived and asks you to run codex unarchive with its id first. Unarchive it, then run codex exec resume again.
Where do I find the session id?
codex exec prints it on the session id line of the header at the start of every run. Save it from the run that created the session and pass it to the next one.
Where Crowsnest fits
Crowsnest includes non-interactive Codex runs in its local gallery by asking app-server for those source kinds. It does not turn arbitrary shell pipelines into managed Crowsnest tasks.
Source and version
The exact text and flags on this page were checked against the installed codex-cli 0.146.0 binary on November 19, 2026. Version-specific behavior can change, so compare your own --help output before scripting around it. Official CLI documentation →
Reviewed from first-party CLI output and the released Crowsnest product source. No command on this page bypasses provider limits, billing, authentication, or native history rules.