Skip to content

fix(core): keep background shell locations alive - #52580

Open
opencode-agent[bot] wants to merge 1 commit into
devfrom
background-eviction
Open

opencode-agent[bot] wants to merge 1 commit into
devfrom
background-eviction

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep a Location's services cached while a shell job started there remains backgrounded and running. Capture the shell's owning Location at job start rather than inferring it later from a Session that may have moved.
  • Recheck for shells admitted during eviction cleanup before detaching the cached graph.
  • Do not pin a parent Location just because it is waiting on a background sub-agent in another Location; completion enters the parent's durable inbox and wakes it normally.

Validation

  • SHELL=/bin/bash bun test test/location-activity.test.ts test/browser-idle.test.ts test/job.test.ts test/tool-shell.test.ts (88 pass, 42 platform skips)
  • bun typecheck from packages/core
  • bun --bun run lint from repo root
  • Full bun run check unavailable on this host's Node 18 (Astro requires Node >=22.12); attempting the whole-workspace check with Bun also hit a host-wide concurrent typecheck crash. Scoped checks above passed.

Requested by: @jlongster (James via Slack)

@SamSpiri

SamSpiri commented Oct 3, 2026

Copy link
Copy Markdown

Supporting data for this PR — it fixes the notification-loss half of the eviction bug, not just the shell kill.

Independent repro on v2.0.22: background: true shell job launched at 18:02, worker idle at 18:03:05 (last durable event in the location), 60-min TTL evicts the location ~19:03, job actually finishes 19:11:33 — and no synthetic completion row is ever written (verified absent in session_message; session_inbox/session_pending empty). The .out file is also removed, matching the watcher's Effect.onInterrupt(() => shell.remove(...)) (tool/plugin/shell.ts:234). The waiting session stayed idle until woken manually 70 min later.

A second background job in the same session that ran < 60 min delivered normally, confirming the path works when the location survives.

Because notifyWhenDone is forkIn'd into the location/plugin scope, keeping the location's services cached while a backgrounded shell is live (as this PR does) is exactly what preserves sessions.synthetic(...) and the auto-resume. Kindly prioritise; this strands any background: true job that outlives the idle TTL, which is a common long-running-build/test pattern.

This branch has not been deployed

No deployments
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.

2 participants