You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
service: background shell silently killed when idle location is evicted; completion notification never delivered #58049
Background shells (shell tool with background=true) are tied to the location's lifecycle. When the service evicts an idle location, running background shells are killed, their output files are deleted, and the promised "you will be notified when it completes" event is never delivered — the agent waits forever with no signal.
Environment
opencode version: 2.0.32
OS: Windows_NT 10.0.19045 (win32 x64)
Terminal: TUI (TERM=xterm-256color)
Shell: PowerShell (pwsh) spawned by the service
Install/channel: latest (autoupdate disabled)
Active plugins: none configured; one MCP server (playwright, via npx)
Reproduction
In a session, start a background shell that outlives the location idle window (e.g. a watcher loop polling a remote host every 3 min; observed death after ~60 min idle).
Let the session go idle between turns so the service evicts the location.
Service log shows message="location services evicted" and later message="location services booted" on next access.
The background shell process is gone; its output file under ~/.local/share/opencode/shell/<hash>/ is deleted; no completion/termination event reaches the session. GET /api/shell/<id>/output returns 4xx.
Expected Behavior
The documented contract "you will be notified automatically when the command finishes" should not silently break. Any of: (a) don't evict a location with running background shells; (b) deliver a termination event (with reason) to the owning session on eviction; (c) own background shells at service level instead of location level.
Actual Behavior
Shell killed without notice, output file removed, session never woken. A second identical watcher that completed before the eviction delivered its notification normally, isolating the failure to eviction.
Additional Context
The service process itself never restarted (same PID before/after) — not a crash, purely location lifecycle.
Timeline: watcher started 15:21 -> location services evicted 16:22:24 (INFO) -> user's GET /api/shell/<id>/output 404 at 16:22:24 -> location services booted.
After the re-boot, MCP tools re-registered and the next user message showed "Instructions updated: core/codemode" — consistent with full location re-initialization.
Frequency: observed once, timing-consistent; presumably deterministic whenever eviction happens while a background shell runs.
Workaround: re-arming the watcher only postpones the same outcome.
Thanks for the detailed timeline. I think this is a duplicate of #51828: a location is evicted after 60 minutes of inactivity, which kills its running background shells and loses their completion notification.
Possible duplicates and related issues, ordered by likelihood:
On the current code, the idle sweep no longer evicts a location that has running background jobs (#57416). That change shipped in v2.1.0, so it is not in 2.0.32. v2.1.0 and later also add an experimental.location_idle_timeout option (#57476). With autoupdate disabled, you may want to upgrade manually and check whether it still happens.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if it still happens on 2.1.x.
Closing as duplicate of #51828 per triage. Fix verified on 2.1.3 on this machine: a 90-minute background shell with the session fully idle survived past the 61-minute eviction mark and delivered its automatic completion notification; output file intact; no eviction entry for the workspace directory during the window (data point posted on #51828, 2026-10-23).
We haven't heard back in the last day, so I'm closing this as a duplicate of #51828, which reports the same bug: background shells are killed and their completion notification is lost when an idle location is evicted. Please follow that issue for updates.
The fix (#57416) shipped in v2.1.0: the idle sweep no longer evicts a location that has running background jobs. Since autoupdate is off on your machine, you'd need to upgrade manually to get it. If this still happens on 2.1.x, please comment here or on #51828 with the version and service log lines, and we can reopen.
Activity
opencode-agent commentedon Oct 22, 2026
Thanks for the detailed timeline. I think this is a duplicate of #51828: a location is evicted after 60 minutes of inactivity, which kills its running background shells and loses their completion notification.
Possible duplicates and related issues, ordered by likelihood:
On the current code, the idle sweep no longer evicts a location that has running background jobs (#57416). That change shipped in v2.1.0, so it is not in 2.0.32. v2.1.0 and later also add an
experimental.location_idle_timeoutoption (#57476). With autoupdate disabled, you may want to upgrade manually and check whether it still happens.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if it still happens on 2.1.x.
luoming319-cloud commentedon Oct 23, 2026
Closing as duplicate of #51828 per triage. Fix verified on 2.1.3 on this machine: a 90-minute background shell with the session fully idle survived past the 61-minute eviction mark and delivered its automatic completion notification; output file intact; no eviction entry for the workspace directory during the window (data point posted on #51828, 2026-10-23).
opencode-agent commentedon Oct 23, 2026
We haven't heard back in the last day, so I'm closing this as a duplicate of #51828, which reports the same bug: background shells are killed and their completion notification is lost when an idle location is evicted. Please follow that issue for updates.
The fix (#57416) shipped in v2.1.0: the idle sweep no longer evicts a location that has running background jobs. Since autoupdate is off on your machine, you'd need to upgrade manually to get it. If this still happens on 2.1.x, please comment here or on #51828 with the version and service log lines, and we can reopen.