Add session support to "codex exec"
Resolved 💬 7 comments Opened Sep 1, 2025 by sldx Closed Sep 3, 2025
💡 Likely answer: A maintainer (gpeal, contributor)
responded on this thread — see the highlighted reply below.
What feature would you like to see?
Currently, you can execute arbitrary prompts from the command line using
codex exec "Build a Tetris game"
However, this is a single shot with no option to continue the conversation. This is extremely limiting.
Claude Code has support for sessions, so you can send a command (with -p in their case) and add a session ID so that this message can be part of a longer conversation. This vastly increases the usefulness of this mode.
Please add something similar to Codex CLI
Are you interested in implementing this feature?
No
Additional information
_No response_
7 Comments
Why don't you start the session with codex and then work with it? No need for exec in this case.
Huh?
codex execexists because it's useful in some automated situations where codex TUI can't be used. In those cases, having a session in the TUI doesn’t really help.I guess the best workaround for now is to have
codex execoutput in JSON and then parse & use that (or LLM-compressed) as input for the next run. But I feel session support should be table stakes for this kinda tool. +1 on the request, would've needed this yesterday as well.It's supported with
experimental_resume = $session_file_pathIt will pull the session if you specify it in the cli, doesn't seem to work if I put it in config.toml
echo what did we talk about | codex exec -c experimental_resume=$session_json_pathWould you mind educating me on how to use the command?
SessionID-related issues/pull
https://github.com/openai/codex/pull/2377
https://github.com/openai/codex/issues/2434
https://github.com/openai/codex/pull/2377
$session_pathis a path to file that has something like this inside{"id":"b9c2b331-ffde-46c2-90e5-b763816c0bc8","timestamp":"2025-09-03T07:52:14.977Z"}If you put that file in the same dir you are running the command from and the file is named session.jsonl the command will be:
echo what did we talk about | codex exec -c experimental_resume=session.jsonl`
duplicate of 1991
@gpeal wait what? No it's not the same thing. That issue is about resuming an interactive session. This is about using the
execparam, non-interactive