Skip to content

Add ability to duplicate/fork conversation sessions (like Cursor's chat duplication) #3487

Closed

Description

@crayment

Problem/Use Case

When working with OpenCode, I often want to experiment with different approaches to solving a problem without losing my current conversation state. Currently, if I want to try a different direction, I either have to:

  • Continue in the same chat and lose the original context if it doesn't work out
  • Use /undo repeatedly, which is cumbersome for exploring alternatives
  • Start a completely new session and lose all the accumulated context

Proposed Solution

Add a "duplicate session" feature similar to Cursor's chat duplication. This would create a copy of the current conversation at its current state, allowing users to:

  • Try different implementation approaches in parallel
  • Create "save points" before making risky changes
  • Compare different solutions side-by-side
  • Experiment freely without fear of losing good progress

How it works in Cursor

In Cursor (the VSCode fork), users can duplicate a chat conversation at any point. This creates an exact copy of the conversation history up to that moment, and both the original and duplicate exist independently. It's like creating a save point in a game - you can explore different paths without losing your progress.

Suggested Implementation

  • Add a /duplicate or /fork command
  • Or a keyboard shortcut (e.g., Ctrl+D)
  • The duplicated session should maintain full conversation history
  • Both sessions should be independently browsable/switchable in the TUI

Benefits

  • Encourages experimentation without risk
  • Reduces cognitive load when exploring multiple solutions
  • Improves workflow efficiency for complex refactoring decisions

Activity

  1. rekram1-node commented on Oct 28, 2025

    @rekram1-node
    Contributor

    We have forking ready to go, it will ship when opentui version is released.

  2. crayment commented on Oct 28, 2025

    @crayment
    ContributorAuthor

    Amazing!!! So happy to hear 😄

  3. malhashemi commented on Oct 30, 2025

    @malhashemi
    Contributor

    Hi guys,

    Just made a plugin that gives your agents a session management tool (allows for forking and more). If you would like to allow your agents the ability to do that pair it with some slash commands and/or system prompt to do that autonomously - appreciate your feedback opencode-sessions

  4. crayment commented on Oct 30, 2025

    @crayment
    ContributorAuthor

    @malhashemi I tried using this plugin for forking but ran into issues.

    First attempt: Recursive fork cascade - the forked agent immediately tried to fork again, creating 12 sessions in 47 seconds until I interrupted it.

    Second attempt: I created a fork-child agent with the session tool disabled:

    {
      "agent": {
        "fork-child": {
          "description": "Build agent for forked sessions - cannot fork further",
          "mode": "primary",
          "tools": {
            "session": false
          }
        }
      }
    }

    Then forked with:

    session({
      mode: "fork",
      agent: "fork-child",
      text: "Investigate X..."
    })

    This prevented the cascade, but the forked agent just gave up when it realized it didn't have the session tool available. It complained about not having access and stopped working instead of proceeding with the actual task.

    The context from the parent conversation (where we were heavily discussing the session tool) seems to strongly bias the forked agent to try using it, even when explicitly instructed not to in the prompt.

    Not sure if this is a plugin issue or just how context preservation works with fork mode, but it made the tool unusable for my "save point" use case (fork to explore, keep parent as stable base).

  5. malhashemi commented on Nov 3, 2025

    @malhashemi
    Contributor

    @crayment I was trying to replicate your issue but failed to do so, can you help me by elaborating on which model were you using? I use sonnet-4.5 for 99 percent of my use cases. And it doesn't seem to get confused. Also have you tried with a conversation without the bias? Is this a consistent issue? You are correct in the end the tool is just a tool and it is up to the agent and the prompt to decide when to use it. The tool job is to fork the conversation and to send the message specified by the agent after the fork, so it has no control on the agent's behaviour or adherence to the message that gets sent.

  6. rekram1-node commented on Nov 3, 2025

    @rekram1-node
    Contributor

    You can now fork chats in v1, click a message -> select fork

  7. crayment commented on Nov 6, 2025

    @crayment
    ContributorAuthor

    @rekram1-node is the fork capability available via API? https://opencode.ai/docs/server/

    If not and you guide me I'd be willing to attempt to contribute that as a PR. ATTEMPT!

  8. rekram1-node commented on Nov 6, 2025

    @rekram1-node
    Contributor
  9. crayment commented on Nov 6, 2025

    @crayment
    ContributorAuthor

    @rekram1-node Thanks!! Two follow up questions:

    1. I need to point an agent at that file and have it understand the latest API spec anyway. Want me to attempt to update the docs and submit a PR?
    2. What do you use to manage your github notifications that allows you to reply so quickly! While also shipping so many updates?? Appreciate your work on this!!
  10. rekram1-node commented on Nov 6, 2025

    @rekram1-node
    Contributor

    @crayment i just check them a lot hahaa

    sure thatd be great

    also for api spec you can do “opencode generate” and it should output an openapi spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions