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

Closed
opened 2026-02-16 17:35:03 -05:00 by yindo · 10 comments
Owner

Originally created by @crayment on GitHub (Oct 27, 2025).

Originally assigned to: @thdxr on GitHub.

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
Originally created by @crayment on GitHub (Oct 27, 2025). Originally assigned to: @thdxr on GitHub. ## 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
yindo closed this issue 2026-02-16 17:35:03 -05:00
Author
Owner

@rekram1-node commented on GitHub (Oct 28, 2025):

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

@rekram1-node commented on GitHub (Oct 28, 2025): We have forking ready to go, it will ship when opentui version is released.
Author
Owner

@crayment commented on GitHub (Oct 28, 2025):

Amazing!!! So happy to hear 😄

@crayment commented on GitHub (Oct 28, 2025): Amazing!!! So happy to hear 😄
Author
Owner

@malhashemi commented on GitHub (Oct 29, 2025):

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

@malhashemi commented on GitHub (Oct 29, 2025): 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](https://github.com/malhashemi/opencode-sessions)
Author
Owner

@crayment commented on GitHub (Oct 30, 2025):

@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).

@crayment commented on GitHub (Oct 30, 2025): @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: ```json { "agent": { "fork-child": { "description": "Build agent for forked sessions - cannot fork further", "mode": "primary", "tools": { "session": false } } } } ``` Then forked with: ```javascript 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).
Author
Owner

@malhashemi commented on GitHub (Nov 3, 2025):

@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.

@malhashemi commented on GitHub (Nov 3, 2025): @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.
Author
Owner

@rekram1-node commented on GitHub (Nov 3, 2025):

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

@rekram1-node commented on GitHub (Nov 3, 2025): You can now fork chats in v1, click a message -> select fork
Author
Owner

@crayment commented on GitHub (Nov 5, 2025):

@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!

@crayment commented on GitHub (Nov 5, 2025): @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!
Author
Owner

@rekram1-node commented on GitHub (Nov 5, 2025):

yes but our docs are always out of date we need to auto gen them:

https://github.com/sst/opencode/blob/7c098c8849ef25eae38219fb6effa919476e6162/packages/opencode/src/server/server.ts#L541

@rekram1-node commented on GitHub (Nov 5, 2025): yes but our docs are always out of date we need to auto gen them: https://github.com/sst/opencode/blob/7c098c8849ef25eae38219fb6effa919476e6162/packages/opencode/src/server/server.ts#L541
Author
Owner

@crayment commented on GitHub (Nov 6, 2025):

@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!!
@crayment commented on GitHub (Nov 6, 2025): @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!!
Author
Owner

@rekram1-node commented on GitHub (Nov 6, 2025):

@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

@rekram1-node commented on GitHub (Nov 6, 2025): @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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2303