non-interactive support for fork

Resolved 💬 5 comments Opened Jan 28, 2026 by dmahurin Closed Mar 20, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

Support non-interactive fork, similar to /fork.

Consider the following scenario:

codex exec "Create hello world example in hello.py"
# Now we are at a checkpoint, so we fork.
codex exec fork --last

codex exec "Create a similar program in C."  resume --last 
codex exec "Create a similar program in Javascript."  resume --last

Now we decide that the additional programs were not needed, We re-fork.

codex exec resume --parent
codex exec fork --last

Or we could just re-fork with:

codex exec fork --parent

The changes implied in above:

  • Add support for 'exec fork', which creates a new derrived session and exits.
  • exec fork could allow --last, --parent or a specific session id.

Optional changes would be similar for exec resume:

  • Allow codex exec resume to work without prompt. Without a prompt, it would just reset the current session (if needed) and exit.
  • Allow --parent to be passed to exec resume.

The above allows forking at some checkpoint, and going back to that checkpoint non-interactivly, without determining session id's.

As an alternative to using --parent, codex could expose /status as 'codex exec status'. This could allow:

parent=$(codex exec status | grep 'Forked from:' | sed 's/.: //')"

Additional information

_No response_

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 7 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #8612
  • #8614

Powered by Codex Action

dmahurin · 6 months ago

Until fork, status and other commands are available with exec, a crude workaround is to run codex in a pty and run the slash commands.

You can use this to run codex commands non-interactively. It is currently specific to codex.
https://github.com/dmahurin/pty-runner

Examples:
pty-runner codex ... /status /exit
pty-runner codex ... /fork /status /exit

etraut-openai contributor · 5 months ago

This feature request hasn't received enough upvotes, so closing.

btomaj · 2 months ago
etraut-openai contributor · 21 days ago

This will be included in the next release.