No way to resume in non-interactive mode when session id is not outputted

Resolved 💬 7 comments Opened Sep 17, 2025 by jordan-BAIC Closed Oct 31, 2025
💡 Likely answer: A maintainer (pakrym-oai, contributor) responded on this thread — see the highlighted reply below.

codex-cli 0.36.0

codex exec --json "<my message>" does not return a session id, and therefore I cannot then perform codex exec --json resume <session_id> "<my followup message"

using codex proto seems to have the opposite problem, it returns a session id but is not capable of resuming with it.

My workaround for now if getting the latest session id from the ~/.codex/sessions directory, but my application lets you run multiple prompts in rapid succession so this is not reliable.

View original on GitHub ↗

7 Comments

skeskinen · 10 months ago

Facing the same issue with vibe-kanban.

codex-cli 0.38.0 & codex-cli 0.39.0

eadlam · 9 months ago

You can use --last with exec.

milisp · 9 months ago

@eadlam
I built a GUI for Codex CLI

GUI needs proto

https://github.com/milisp/codexia

pakrym-oai contributor · 9 months ago

Hi, can you please try codex exec --experimental-json (will soon become the default --json behavior) that returns thread_id in combination with codex exec resume <thread_id>?

varunursekar · 9 months ago

@pakrym-oai This kind of works, however, cli flags and arguments from the first invocation aren't preserved in subsequent ones - in the screenshot below you can see that when we resume, it no longer outputs JSON. Maybe for JSON this isn't so bad, but there are other arguments (e.g. skip-git-repo-check) that preclude this workaround.

<img width="1123" height="487" alt="Image" src="https://github.com/user-attachments/assets/8a7ffe55-f276-4705-93a6-7061d950e5fa" />

pakrym-oai contributor · 9 months ago

The current command line parsing logic is a bit deficient and requires arguments to go between codex exec and resume
try codex exec --experimental-json <other args> resume ... .

We are aware and working on this.