Skip to content

[FEATURE]: Add cli flag to fork session #11137

Closed

Description

@moonray

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I know there is a fork ability in ui, but it would be great if we could fork using a cli flag for better automation and tooling.

Claude uses the following:

  --fork-session                                    When resuming, create a new session ID instead of reusing the original (use with --resume or --continue)

e.g.

opencode --continue --fork-session

or

opencode --session [session_id] --fork-session

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 29, 2026
  2. github-actions commented on Jan 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if this request is specifically about a direct CLI flag approach (--fork-session) rather than ACP or /branch command.

  3. ariane-emory commented on Jan 30, 2026

    @ariane-emory
    Contributor

    Normally forking happens on a specific message within a session. Is your intent that it would automatically fork on the last/most-recent message in the session (i.e, using this on a session with one message in it would be equivalent to starting a new session)?

  4. moonray commented on Jan 30, 2026

    @moonray
    Author

    For CLI based forking, Claude Code's session behavior seems optimal to me, not forking before the last message.
    https://code.claude.com/docs/en/how-claude-code-works#resume-or-fork-sessions

  5. ariane-emory commented on Jan 30, 2026

    @ariane-emory
    Contributor

    @moonray Well, alright... I do not use Claude Code, so I'm just trying to understand this from the documentation that you linked:

    1. The --fork-session switch essentially just duplicates the session in question and then loads that duplicate?
    2. Should we retain OpenCode's current behaviour of re-titling forked sessions to something like Some session (fork #1), even though we aren't truly 'forking' the session per se (but rather are simply duplicating it)? I would assume that that would be desirable, but I could be mistaken.
    3. This switch must be used in conjunction with --continue or --session, opencode --fork-session would be non-sensical?

    If I am understanding your intent correctly, I could take a stab at this and see what I can cook up.

  6. moonray commented on Jan 30, 2026

    @moonray
    Author
    1. That is correct. It's still a fork, if you continue in both sessions, though. :)
    2. The current opencode titling makes the most sense
    3. Correct. You cannot fork without a session id, or you're simply creating a new session. --continue is simply shorthand for providing the last used session id. So it must be used in conjunction with either --continue or --session [session id]
  7. added 2 commits that reference this issue on Jan 30, 2026
    7588374
    3806a40
  8. ariane-emory commented on Jan 30, 2026

    @ariane-emory
    Contributor

    @moonray Alrighty then... I rolled the dice a few times, had a few different models try their out their own takes on this feature, then tossed them into the arena to let yet another set of models review these and assess the best amongst them. I've now submitted a PR for the take that was deemed the best of the bunch, which can be found here: #11340.

    Fingers crossed that the maintainers will like it!

  9. 71 remaining items

  10. added a commit that references this issue on Feb 10, 2026
    4374c5c
  11. added a commit that references this issue on Feb 10, 2026
    034a8a4
  12. added a commit that references this issue on Feb 17, 2026
    efae775
  13. added a commit that references this issue on May 5, 2026
    d75521a
  14. added a commit that references this issue on Jun 14, 2026
    8d3385a
  15. added a commit that references this issue on Jul 31, 2026
    3d77b92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions