Skip to content

[FEATURE]: Allow custom session ID when starting Opencode (e.g., --session my-project) #17344

Closed as not planned

Description

@seekskyworld

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

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:

  1. Start a session with a meaningful name
  2. Resume the same session later using the same session ID
  3. Organize multiple projects more easily
  4. 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.

Activity

  1. added
    discussion
    on Mar 13, 2026
  2. added
    core
    on Mar 13, 2026
  3. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    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.

  4. ericwooley commented on Apr 20, 2026

    @ericwooley

    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.

  5. removed
    discussion
    core
    on May 3, 2026
  6. mobiuscog commented on May 14, 2026

    @mobiuscog

    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.

  7. matic-pecovnik commented on Jul 13, 2026

    @matic-pecovnik

    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:

    1. Start opencode run
    2. Stream process output
    3. Parse/wait for generated session ID
    4. 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.
  8. github-actions commented on Sep 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  9. mtt-ableton commented on Sep 14, 2026

    @mtt-ableton

    I wish that this would be planned.

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