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
{{ message }}
Repository navigation
[FEATURE]: Allow custom session ID when starting Opencode (e.g., --session my-project) #17344
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Currently, Opencode automatically generates a session ID when starting a new session. While this works well, it makes it difficult to organize or intentionally resume sessions for specific projects.
I would like to request support for manually specifying a session ID when launching Opencode, similar to how OpenClaw allows custom session identifiers.
Example:
opencode --session my-project
With this feature, users could:
Start a session with a meaningful name
Resume the same session later using the same session ID
Organize multiple projects more easily
Avoid relying only on auto-generated session IDs
Example workflow:
Start a session:
opencode --session my-project
Later resume the same session:
opencode --resume my-project
Benefits:
Better project-based session organization
Easier session recovery
More predictable workflows when using Opencode for multiple tasks
Improved scripting and automation possibilities
This feature would be especially useful for developers who use Opencode across multiple repositories or long-running development sessions.
If session IDs are currently auto-generated internally, this could potentially be implemented as an optional override flag while keeping the current default behavior unchanged.
Reacted by Tobias Gårdhus, Hidde de Jong, Wahab Alshahin, Lucas Arthur Felgueiras, U Cirello, Nejc Habjan, Matthieu Talbot, Jacob Aschenwald, Rich Evans, matic-pecovnik and 3 more
Today, I had opencode open in a session, within a project directory.
I then ran a second instance, in a different directory, with -c (because I don't want new sessions every time if one exists for a project), and it connected to the same session, which was really confusing as I would expect sessions to be contained within project roots.
Being able to specify a sessionID (and have it create/resume as necessary) would make the workflow so much easier and predictable.
My use case is embedding opencode run inside another workflow where I want to link users to the session and open it in a TUI immediately when the run starts.
Today, because the session ID is generated internally, the integration has to:
Start opencode run
Stream process output
Parse/wait for generated session ID
Update UI/state after process already started
That works, but adds complexity and delays visibility into the run.
If opencode run allowed passing an ID up front, for example:
opencode run --session-id <id>
then external tools like mine could create links and open session views without the additional complexity of streaming the terminal output, while default behavior could remain unchanged when no ID is provided.
Expected behavior I would hope for:
Omitted flag keeps current generated-ID behavior
Provided ID is used for created session
Existing/invalid ID fails early with clear error
This would make OpenCode much easier to embed in dashboards, TUIs, and other automation at least as I have done it.
Reacted by Denis Nedelyaev, jaderocks, Marc Cerutti and Nifury
Activity
github-actions commentedon Mar 13, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and consider adding your thoughts there instead of opening a new one.
ericwooley commentedon Apr 20, 2026
I just wanted to bump this as it's something I really need.
To add a use case, I'm writing scripts to start ai tools based on branch name in a worktree
I would love to run `opencode --session=$(echo -n $(git branch --show-current) | md5sum | cut -d ' ' -f 1) run 'Some arbitrary prompt'
Then be able to come back to the session deterministically later.
mobiuscog commentedon May 14, 2026
This is something I would really find useful.
Today, I had opencode open in a session, within a project directory.
I then ran a second instance, in a different directory, with -c (because I don't want new sessions every time if one exists for a project), and it connected to the same session, which was really confusing as I would expect sessions to be contained within project roots.
Being able to specify a sessionID (and have it create/resume as necessary) would make the workflow so much easier and predictable.
matic-pecovnik commentedon Jul 13, 2026
My use case is embedding
opencode runinside another workflow where I want to link users to the session and open it in a TUI immediately when the run starts.Today, because the session ID is generated internally, the integration has to:
opencode runThat works, but adds complexity and delays visibility into the run.
If
opencode runallowed passing an ID up front, for example:then external tools like mine could create links and open session views without the additional complexity of streaming the terminal output, while default behavior could remain unchanged when no ID is provided.
Expected behavior I would hope for:
This would make OpenCode much easier to embed in dashboards, TUIs, and other automation at least as I have done it.
github-actions commentedon Sep 12, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
mtt-ableton commentedon Sep 14, 2026
I wish that this would be planned.