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:
Once we settle on the UX and expected behavior, I’m happy to do the work.
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 runalways 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 usingopencodeinside: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 runthat:A rough UX idea (open to alternatives):
opencode run --ephemeral "…"opencode run --no-session "…"Some constraints that seem reasonable:
--continue/--sessiontogether with--ephemeral).--attachis used, ephemeral mode may be disallowed (or clearly defined) since the remote server controls persistence.Why this is useful
opencode runfeel 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
--ephemeralvs--no-sessionvs something else?run, or be a more general session option?Persistence semantics
Compatibility rules
--ephemeralinteract with:--continue,--session--attach--share/ auto‑share configOnce we settle on the UX and expected behavior, I’m happy to do the work.