Repository navigation
feat(opencode): OpenCode ephemeral sessions - #43656
Closed
5herlocked wants to merge 10 commits into
Closed
5herlocked wants to merge 10 commits into
5herlocked wants to merge 10 commits into
Conversation
5herlocked
marked this pull request as draft
August 20, 2026 15:22
5herlocked
force-pushed
the
ephemeral-run
branch
from
August 20, 2026 15:31
9db9f7f to
2af60a7
Compare
5herlocked
marked this pull request as ready for review
August 20, 2026 15:40
5herlocked
marked this pull request as draft
August 20, 2026 21:01
5herlocked
marked this pull request as ready for review
August 20, 2026 21:12
|
Address review feedback on anomalyco#43656: - Process-owned heartbeat bumps time_updated for ephemeral sessions every 10 minutes while the creating process lives, so idle-but-alive runs (pending permission asks, open ephemeral TUIs) are never reaped by the startup sweep. Beats stop with the process, preserving sweep semantics. - Exit-time session deletion is wrapped in a 5s timeout in both run and tui paths so a hung delete cannot wedge the process at exit; the sweep covers stragglers. - Usage-projection heartbeat now stamps event time instead of wall clock, keeping projection replay deterministic.
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #4489
Potentially enables #40863
Type of change
What does this PR do?
Adds ephemeral sessions as a core concept to OpenCode server, then exposes the functionality through the
--ephemeralflag.Server owns the ephemeral sessions and cleans them up when
(now() - time_updated) >= 24h(to permit long running ephemeral tasks). We reuse time_updated as it's the codebases' indicator for last observed activity.There are also client side updates to promptly delete ephemeral sessions as soon as they end / are terminated through
SIGINT / SIGTERM. Note -SIGKILLleaves the session in the DB for the 24h period as a way to recover killed sessions assuming they need to be recovered.How did you verify your code works?
Various unit tests + functional testing by compiling the branch, and testing 10 ephemeral sessions to make sure they don't show up in the UI + the DB (assuming they were terminated properly). Tested against Bedrock to ensure long running sessions are still cleaned up when
SIGINT/SIGTERMbut live on whenSIGKILLEnd-to-end (compiled from source, isolated data dir, real provider: Bedrock us-east-1 / claude-sonnet-5)
ephemeral=0session/message/part/session_input/eventephemeral=1) but hidden fromsession listkill -9mid-runtime_updated)--session <id>)Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.
I have used LLM generated code in this PR, and have personally reviewed all of it.
There is a more philosophical question that the
SIGKILLrecovery raises -- if a use recovers a session (through opencode --session <ephemeral_session_id>) that was ephemeral and then killed, should the ephemeral flag persist (causing sweep >= 24h aftertime_updated)?And do we then create a flag under
session listthat lets us list ephemeral sessions that haven't been sweeped yet.