Skip to content

How do I find session ids for -s/--session? #4557

Closed

Description

@jdanbrown

Question

How do I find the session ids to use with opencode --session <session-id> to continue or resume a previous session?

$ opencode --help | grep -- --session
  -s, --session     session id to continue                              [string]
  • When I run the /sessions command, I see (non-unique) names and timestamps, but no ids
  • Maybe it'd be helpful to add an opencode sessions sub-command to the cli to list sessions with their ids, for the user to copy/paste into -s/--session

Activity

  1. rekram1-node commented on Nov 20, 2025

    @rekram1-node
    Collaborator

    u can use opencode export or opencode run if u use run with the --format json flag. But youre correct we need that sessions list command

  2. self-assigned this
    on Nov 20, 2025
  3. rekram1-node commented on Nov 20, 2025

    @rekram1-node
    Collaborator

    /oc Read cmd/ directory, introduce a new command called session, it should have a subcommand called "list" so youd call it like:
    opencode session list

    It should function kinda like how git log works where it paginates if possible and it should show session ids in a way or with flag in a way it could easily be used in a ci script if needed

  4. opencode-agent commented on Nov 20, 2025

    @opencode-agent
    Contributor

    Created PR #4558

    New%20session%20-%202025-11-20T21%3A50%3A32.854Z
    opencode session  |  github run

  5. jdanbrown commented on Nov 20, 2025

    @jdanbrown
    ContributorAuthor

    Nice!

    Another interim workaround: grep around under ~/.local/share/opencode/ to find the ses_* id. 🙃

    ~/.local/share/opencode $ rg 'clean up my alignment code'
    storage/part/msg_a9e135a170018Ui4RfAZfIDlfl/prt_a9e135a17002vkzEexEqH2pup3.json
    6:  "text": "clean up my alignment code in @src/ios/TasksView_i.swift "
    
    ~/.local/share/opencode $ cat storage/part/msg_a9e135a170018Ui4RfAZfIDlfl/prt_a9e135a17002vkzEexEqH2pup3.json
    {
      "id": "prt_a9e135a17002vkzEexEqH2pup3",
      "sessionID": "ses_561eca5ebffeCngoybZWxbTrD8",
      "messageID": "msg_a9e135a170018Ui4RfAZfIDlfl",
      "type": "text",
      "text": "clean up my alignment code in @src/ios/TasksView_i.swift "
    }
  6. daniel-fahey commented on Nov 22, 2025

    @daniel-fahey

    Another workaround is to use a very simple tool, like this:

    $ cat .opencode/tool/get-current-session-id.ts 
    import { tool } from "@opencode-ai/plugin"
    
    export default tool({
      description: "Get the current session ID",
      args: {},
      async execute(args, context) {
        return context.sessionID
      },
    })
  7. jazzyalex commented on Nov 29, 2025

    @jazzyalex

    Requires extra tool - Agent Sessions. I recently added OpenCode support. You can visually or via search find your sessions and then copy ID from a toolbar - will get something like - ses_533cded24ffeEg9nWRBZHMGN7c

    jazzyalex.github.io/agent-sessions
    native macOS app (signed and notarized)• open source

    ses_533cded24ffeEg9nWRBZHMGN7c

    Image
  8. chenyuejie commented on Nov 30, 2025

    @chenyuejie

    Can we specify a session ID when starting opencode? But don't be like Claude Code which insists on using UUIDs — make it like tmux where you can specify any name you want.

  9. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Collaborator

    @0xRango yes but you're gonna be unhappy because its not user friendly ids

  10. chenyuejie commented on Dec 3, 2025

    @chenyuejie

    @0xRango yes but you're gonna be unhappy because its not user friendly ids

    Yes, so I wish I could define session id myself. Claude Code currently only supports adding -c to continue the last session — it's too difficult to resume other sessions.

  11. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Collaborator

    we allow u to do -c and --session

    for OP:

    added session list command in next release: a8ad74a

  12. chenyuejie commented on Dec 3, 2025

    @chenyuejie

    we allow u to do -c and --session

    for OP:

    added session list command in next release: a8ad74a

    Hi, I found that --session arg not support for custom session id, like --session-id of claude code. but the UUID s are very user-unfriendly. Can we use custom session id, like --session project1 to start new one or continue session?

  13. jdanbrown commented on Dec 3, 2025

    @jdanbrown
    ContributorAuthor

    Thanks! Confirmed opencode session list is now working in 1.0.129.

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