Forking sessions
Resolved 💬 6 comments Opened Sep 30, 2025 by varunursekar Closed Nov 12, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What feature would you like to see?
The CLI permits resumption of a past session via the resume command. I am interested in creating multiple continuations of a past session. As such, an option to "fork" a session would be of value. Ideally, a user can run something like:
codex resume "old-session-id" --fork "new-session-id" ...
This would also provide parity with Anthropic's Claude Agent SDK see [here].
Are you interested in implementing this feature?
Yes
Additional information
_No response_
6 Comments
Thanks for filing this request! I’ve put together a
--forkdesign and would love feedback before implementing it.Proposal Summary
--forkflag (short-f, default off) tocodex resume.--forkis set, the CLI always creates a new branch from the chosen session before launching—whether the user goes through the picker, uses--last, or passes a session ID argument.Detailed Behaviour
codex resume --forkshows the session list; when the user confirms a selection, the CLI forks the session and starts the new branch.If the command ends with an optional
[PROMPT], the new branch launches with that prompt.--last)codex resume --last --forkforks the most recent session and immediately drops into the new branch.If resume gains additional filters later, we can still insert the fork step right after the target session is chosen—no extra compatibility code needed.
codex resume <SESSION_ID> --fork(or--fork <SESSION_ID>) forks the specified session first, then resumes the new branch.The optional
[PROMPT]works exactly as it does today.In the TUI, display a banner such as “Starting a new fork (forked from …)” so it’s obvious we’re in a branch.
In pure CLI mode, print the new session ID after a successful fork.
Compatibility
--forkdoesn’t conflict with existing flags (--last, model/config overrides, positional session ID, etc.).Implementation Notes
ResumeCommandwith afork: boolfield and update the clap definitions/help text.SessionMeta:forkisfalse, keep the current resume flow.forkistrue, call the existingConversationManager::fork_conversationto create the new session, then hand that meta torun_conversation.--lastand direct-ID paths share the same logic.Validation Plan
codex resume --forkin the picker,--last, direct session ID, and other relevant paths.cargo fmt -- --config imports_granularity=Item && cargo clippy --tests && cargo testto keep the codebase clean.Does this approach line up with what you’d expect? I’m happy to revise anything that seems off—just let me know, and once we have consensus I’ll start implementing it. Thanks!
Hi! I just submitted a PR to extend with a flag so that interactive sessions can branch without overwriting the original conversation. It covers TUI picker, , direct ID resumes, core tests, and docs updates. PR: https://github.com/openai/codex/pull/5047 . Happy to adjust if there's anything else you'd like to see.
Closing in favor of #4690, which has more upvotes
I'm sorry @Wangnov I wanted to say that I appreciate the effort you made. I would also love this feature, and was disappointed to see that this was closed.
@rissem, this issue was closed as a duplicate. If you haven't already done so, please upvote (add a thumbs-up reaction to) #4690. And if you think that it doesn't quite capture what you want to see, please post to it.
We generally prioritize features based on community feedback. Duplicate (or largely overlapping) feature requests dilute the upvote counts and make a feature less likely to rise to the top of the priority queue.
Thanks for your reply and I just added a 👍 to #4690. Is there anything beyond that that I can do to get this feature integrated sooner? Or perhaps you know of forks that are more accepting of community contributions?