You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
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 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.
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?
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!!
Activity
rekram1-node commentedon Oct 28, 2025
We have forking ready to go, it will ship when opentui version is released.
crayment commentedon Oct 28, 2025
Amazing!!! So happy to hear 😄
malhashemi commentedon Oct 30, 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
crayment commentedon 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-childagent with thesessiontool disabled:{ "agent": { "fork-child": { "description": "Build agent for forked sessions - cannot fork further", "mode": "primary", "tools": { "session": false } } } }Then forked with:
This prevented the cascade, but the forked agent just gave up when it realized it didn't have the
sessiontool 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
sessiontool) 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).
malhashemi commentedon 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.
rekram1-node commentedon Nov 3, 2025
You can now fork chats in v1, click a message -> select fork
crayment commentedon Nov 6, 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!
rekram1-node commentedon Nov 6, 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
crayment commentedon Nov 6, 2025
@rekram1-node Thanks!! Two follow up questions:
rekram1-node commentedon 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