Skip to content

[FEATURE]: Ephemeral one‑off sessions for opencode run (happy to implement) #4489

@kamilchm

Description

@kamilchm

I’d like to propose and help implement support for ephemeral one‑off sessions in opencode run—and I’m happy to do the implementation work if we can agree on the UX and design.

Right now, opencode run always creates a full session that is persisted to the local session store (e.g. under .local/share/opencode/). This is great for interactive work, but it’s less ideal when using opencode inside:

  • Small utility scripts
  • One‑shot CLIs
  • CI/CD jobs

In these scenarios, each call is “fire‑and‑forget”: I only need the streamed output, not a persistent session that shows up in history.


What I’m proposing

Add an ephemeral mode for opencode run that:

  • Allows a session to exist for the duration of the run (to route events, tools, etc.).
  • Does not persist that session to storage, or deletes it immediately after the run completes.
  • Keeps the behavior of tools, permissions, and output formatting the same as today.

A rough UX idea (open to alternatives):

  • opencode run --ephemeral "…"
  • or opencode run --no-session "…"

Some constraints that seem reasonable:

  • Ephemeral mode is only valid for new sessions (no --continue / --session together with --ephemeral).
  • If --attach is used, ephemeral mode may be disallowed (or clearly defined) since the remote server controls persistence.

Why this is useful

  • Clean session history: Avoids filling the session list with throwaway script/CI runs.
  • Better scripting ergonomics: Makes opencode run feel more like a simple CLI helper for automation, without having to manage session lifecycle explicitly.

Open design questions

I’d love maintainer input on a few points:

  • Exact flag name and scope

    • --ephemeral vs --no-session vs something else?
    • Should this live only on run, or be a more general session option?
  • Persistence semantics

    • Prefer “never write session at all” vs “write then auto‑delete once idle”?
    • Any analytics / usage tracking that depend on persisted sessions and need to be preserved?
  • Compatibility rules

    • How should --ephemeral interact with:
      • --continue, --session
      • --attach
      • --share / auto‑share config

Once we settle on the UX and expected behavior, I’m happy to do the work.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions