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

Closed
opened 2026-02-16 17:38:13 -05:00 by yindo · 12 comments
Owner

Originally created by @jdanbrown on GitHub (Nov 20, 2025).

Originally assigned to: @rekram1-node on GitHub.

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
Originally created by @jdanbrown on GitHub (Nov 20, 2025). Originally assigned to: @rekram1-node on GitHub. ### Question How do I find the session ids to use with `opencode --session <session-id>` to continue or resume a previous session? ```sh $ 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`
yindo closed this issue 2026-02-16 17:38:13 -05:00
Author
Owner

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

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

@rekram1-node commented on GitHub (Nov 20, 2025): 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
Author
Owner

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

/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

@rekram1-node commented on GitHub (Nov 20, 2025): /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
Author
Owner

@opencode-agent[bot] commented on GitHub (Nov 20, 2025):

Created PR #4558

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

@opencode-agent[bot] commented on GitHub (Nov 20, 2025): Created PR #4558 <a href="https://opencode.ai/s/pV7LWIjI"><img width="200" alt="New%20session%20-%202025-11-20T21%3A50%3A32.854Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTExLTIwVDIxOjUwOjMyLjg1NFo=.png?model=opencode/glm-4.6&version=1.0.81&id=pV7LWIjI" /></a> [opencode session](https://opencode.ai/s/pV7LWIjI)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/19552433577)
Author
Owner

@jdanbrown commented on GitHub (Nov 20, 2025):

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 "
}
@jdanbrown commented on GitHub (Nov 20, 2025): Nice! Another interim workaround: grep around under `~/.local/share/opencode/` to find the `ses_*` id. 🙃 ```sh ~/.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 " } ```
Author
Owner

@daniel-fahey commented on GitHub (Nov 22, 2025):

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
  },
})
@daniel-fahey commented on GitHub (Nov 22, 2025): Another workaround is to use a very simple tool, like this: ```console $ 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 }, }) ```
Author
Owner

@jazzyalex commented on GitHub (Nov 29, 2025):

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
@jazzyalex commented on GitHub (Nov 29, 2025): 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](http://jazzyalex.github.io/agent-sessions) native macOS app (signed and notarized)• open source ses_533cded24ffeEg9nWRBZHMGN7c <img width="2724" height="2290" alt="Image" src="https://github.com/user-attachments/assets/80f674a0-b199-4317-9f8e-3b41695affb7" />
Author
Owner

@chenyuejie commented on GitHub (Nov 30, 2025):

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.

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

@rekram1-node commented on GitHub (Dec 2, 2025):

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

@rekram1-node commented on GitHub (Dec 2, 2025): @0xRango yes but you're gonna be unhappy because its not user friendly ids
Author
Owner

@chenyuejie commented on GitHub (Dec 2, 2025):

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

@chenyuejie commented on GitHub (Dec 2, 2025): > [@0xRango](https://github.com/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.
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

we allow u to do -c and --session

for OP:

added session list command in next release: https://github.com/sst/opencode/commit/a8ad74aef3f8b6cd84c76855cbbb30f4fb472b86

@rekram1-node commented on GitHub (Dec 2, 2025): we allow u to do -c and --session for OP: added session list command in next release: https://github.com/sst/opencode/commit/a8ad74aef3f8b6cd84c76855cbbb30f4fb472b86
Author
Owner

@chenyuejie commented on GitHub (Dec 3, 2025):

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?

@chenyuejie commented on GitHub (Dec 3, 2025): > we allow u to do -c and --session > > for OP: > > added session list command in next release: [a8ad74a](https://github.com/sst/opencode/commit/a8ad74aef3f8b6cd84c76855cbbb30f4fb472b86) Hi, I found that --session arg not support for custom session id, like --session-id <uuid> 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?
Author
Owner

@jdanbrown commented on GitHub (Dec 3, 2025):

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

@jdanbrown commented on GitHub (Dec 3, 2025): Thanks! Confirmed `opencode session list` is now working in 1.0.129.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3005