fix(core): retain locations while sessions are executing by kitlangton · Pull Request #47626 · anomalyco/opencode · GitHub
Skip to content

fix(core): retain locations while sessions are executing - #47626

Closed
kitlangton wants to merge 1 commit into
v2from
question-wait
Closed

fix(core): retain locations while sessions are executing#47626
kitlangton wants to merge 1 commit into
v2from
question-wait

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Leave a question unanswered beyond the location inactivity deadline, then submit an answer: the question disappears and the session keeps showing progress indefinitely. Idle cleanup removes the location's cache entry while the running tool still holds its old form service, so subsequent form requests reach an empty replacement and return 404.

What Changes

Before evicting expired locations, consult process-local session execution ownership and resolve those sessions' current locations. Refresh the deadline for an occupied location; continue evicting genuinely idle locations.

Situation Before After
Answer a question after the inactivity deadline Form is unreachable; session stays running Answer reaches the waiting tool; session continues
Dismiss or interrupt a long-pending question Cleanup may have detached its form service Question settles against the original service
Another workspace is idle at the same directory Evicted Still evicted independently
Execution finishes and its location becomes inactive Evicted Still evicted

Location Lifetime

Waiting for human input or a long-running tool need not emit session events. Execution ownership, rather than event silence alone, now protects the location from inactivity eviction.

flowchart LR
  Deadline[Location inactivity deadline] --> Active{Active execution at this location?}
  Active -->|Yes| Retain[Refresh deadline and retain services]
  Active -->|No| Evict[Evict idle location]
Loading

Demo

Same deterministic OpenCode Drive 2.1.0 fixture and Enter keypress on both sides. Before: b2cecc6350. After: ff09490bcc. Real production TUI and question tool with simulated model responses. For both captures only, the existing 60-minute deadline was shortened to 5 seconds and the 1-minute sweep to 1 second; these timing changes are not in the PR. Playback begins after the deadline has elapsed.

question-before-after.mp4

Scope

This change owns inactivity-eviction eligibility and its regression coverage. The production inactivity duration remains 60 minutes.

Verification

# packages/core
bun run test test/location-activity.test.ts test/location-layer.test.ts test/session-execution.test.ts test/form.test.ts
bun typecheck

# packages/server
bun typecheck

# repository root
bunx oxlint packages/core/src/location-activity.ts packages/core/test/location-activity.test.ts
opencode-drive check .drive-output/question-demo.ts
  • 74 focused tests pass. The three new regressions fail on the base revision and pass with the fix.
  • New tests exercise real execution ownership, form waiting, location caching, and inactivity cleanup, with a fixture runner and virtual clock. They cover answer, cancellation, interruption, independent workspace eviction, and eviction after execution settles.
  • Core and Server typechecks pass; focused lint reports no warnings or errors.
  • The required pre-push typecheck passes all 33 configured package tasks.
  • Matched Drive runs verify the baseline remains running after the question disappears and the fixed version completes after answering. The baseline is also recovered by restarting its isolated server against the same database after recording.

@kitlangton

Copy link
Copy Markdown
Contributor Author

@kitlangton kitlangton closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant