Skip to content

[FEATURE]: output session_id after a cli run #17221

@phall1

Description

@phall1

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

the --continue flag is useful, but not if you're running multiple opencodes concurrently. this feature would be a minimal, addition to output the session id after an opencode run to enable:

  1. faster continuation after a run, if running concurrent sessions where the --continue would not work
  2. enable better scripting

POSIX scripting patterns:

# Chain sessions (JSON mode — cleanest):
SID=$(opencode run "first task" --format json | jq -r 'select(.type=="session.complete") | .sessionID')
opencode run --session "$SID" "continue"

# Chain sessions (default mode — stderr parsing):
SID=$(opencode run "first task" 2>&1 >/dev/null | grep '^session:' | awk '{print $2}')
opencode run --session "$SID" "continue"

# Simple — just see it in terminal output:
opencode run "do something"
# ... output ...
# session: ses_abc123

Since UI.println writes to stderr, the session ID never pollutes stdout — piping opencode run "msg" | other_tool works cleanly, and the session ID still appears in the terminal.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions