Repository navigation
fix(core): interrupt sessions before inactivity eviction - #47629
Merged
Merged
Conversation
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
3 of 6 tasks
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.
Why
A session waiting for a question can outlive the location's 60-minute inactivity deadline. Eviction removes the service graph from the cache while its execution still holds the old graph. Answering the question then reaches a replacement
Form.Service: the question disappears, but the original tool keeps waiting and the session never settles.What Changes
Before: inactivity eviction detaches a running execution from the services used by subsequent client requests.
After: inactivity eviction interrupts every active session at that location, waits for tool cleanup and terminal execution settlement, then invalidates the cached graph. The question is cancelled and the TUI shows interrupted.
The execution records
reason: "inactivity"and releases its recovery claim, so a server restart does not resume deliberately expired work. The wait covers the selected execution's settlement, not fresh work admitted during its cleanup. If new work starts in the same or another session, the sweep defers eviction and future sweeps continue. Location comparisons use the cache's canonical path representation, including on Windows.sequenceDiagram participant Activity as LocationActivity participant Execution as SessionExecution participant Tool as Running tools participant Cache as LocationServiceMap Activity->>Execution: interrupt(location's sessions, inactivity, awaitSettlement) Execution->>Tool: interrupt Tool-->>Execution: cleanup complete Execution->>Execution: publish terminal, release recovery claim Execution-->>Activity: selected executions settled Activity->>Execution: check for new active sessions Activity->>Cache: invalidate if location has no active sessionsDemo
eviction-final-comparison.mp4
Matched OpenCode Drive 2.1.0 recording: before
b2cecc6350, after34f77d5877. Both run the real TUI and question tool with an identical simulated model response, 95×30 viewport, and Enter press after expiry. Both temporarily accelerate the existing 60-minute TTL to 5 seconds and the 1-minute sweep to 1 second. Production timings are unchanged. The 10-second comparison shows the initial question, automatic interruption on the right, and the orphaned spinner on the left after Enter.Scope
Owns inactivity-eviction ordering through the existing process-local execution coordinator, plus the durable interruption reason and regenerated client types. Supersedes the active-location retention policy proposed in #47626.
Verification
awaitIdleimplementation and passes with the selected-execution settlement wait.