Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- In an OpenCode thread, ask the agent to start a background task (a subagent or a background command).
- While that task runs, let the next turn fail with a provider error. For me it was the model API returning HTTP 502.
- The background task finishes, and OpenCode starts its own turn to report the result.
I can also reproduce it on main with a fake OpenCode server in a scenario (like scripts/scenarios/opencode-background-result-wakes-thread.e2e.ts): the second prompt sends a session.error with a 502, then the background task finishes and OpenCode answers with the result.
Expected behavior
The result turn runs and shows in the thread, the same way it does when the turn before it did not fail. A user message queued behind it can still wait for the user after the failure.
Actual behavior
The result turn stays queued and held, so the result never shows. On the OpenCode 2 adapter the held turn also counts as background work that is still owed, so switching provider is refused with "The previous provider is still running background agents or commands, and switching would end them...". Only Stop clears it, and then the result is lost.
I think the cause is in startNextQueuedRun in apps/server/src/orchestration-v2/Orchestrator.ts. After a provider failure it holds every queued run, including the buffered wake the CLI started itself (isBufferedProviderNotification). Dispatch already lets these wakes skip a held queue (wakeSkipsHold, from #17885), but this path does not.
Impact
Major degradation or frequent failure
Version or commit
Desktop 0.1.11-nightly.20261117.4814; also reproduced on main @ 49c3ab8
Environment
macOS 26.5.2, T3 Code desktop, OpenCode v2.3.0
Logs or stack traces
# Runs on my thread (read from statev2.sqlite)
run 2 user/web opencode failed 07:58:15.740Z error provider_error, provider.internal, "Provider request failed with HTTP 502"
run 3 agent/provider opencode queued, held requested 07:58:15.819Z (background_task), never started
... provider switch refused at ~08:01:56 and ~08:08:22 ...
run 3 cancelled at Stop 08:09:39.640Z
# Scenario on main with a fake OpenCode server
ordinal status held by src notification
1 completed 0 agent mcp
2 failed 0 agent mcp
3 queued 1 agent provider background_taskScreenshots, recordings, or supporting files
No response
Workaround
Press Stop. It cancels the held turn, but the background result is lost.
Activity