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
- Run a thread on the OpenCode 2 provider (
opencodev2.3.2). - During an active turn, inject multiple mid-turn steers (for example, launching multiple async
delegate_taskchildren while the parent turn remains active so T3 delivers delegated-completion notifications viaprovider-turn.steer->OpenCode2Adapter.steerTurn, back-to-back across a step boundary). - Wait for OpenCode to deliver all steers, finish generating its final assistant reply, and emit
session.execution.succeeded.
Expected behavior
Once OpenCode finishes (session.execution.succeeded) and has no pending inbox items left for that session, OpenCode2Adapter should finish the turn and transition the thread from running to completed.
If turn.steers.size > 0 when session.execution.succeeded arrives, the adapter should reconcile turn.steers against OpenCode's actual inbox / message history (similar to backfill on reconnect) or bound the turn.heldEnd hold instead of waiting forever.
Actual behavior
OpenCode delivers all steers, emits the full final assistant message, and emits session.execution.succeeded cleanly — the OpenCode session is completely idle.
However, T3 Code keeps the thread stuck in status: "running" indefinitely (observed 15+ minutes with zero further activity) because two already-delivered steers remained in turn.steers.
In packages/provider-opencode/src/server/v2/OpenCode2Adapter.ts:
endExecutionwithholds completion wheneverturn.steers.size > 0:if (end.status === "completed" && (turn.steers.size > 0 || goalHoldsTurn(state))) { turn.heldEnd = end; if (goalHoldsTurn(state) && !state.goalRefreshing) yield* refreshGoal(state); return; }
turn.steersis only pruned by live SSEsession.inbox.delivered/session.inbox.cancelledevents (orbackfillif the SSE stream disconnects and reconnects).- When
session.execution.succeededarrives whileturn.steersstill holds stale ID(s), there is no inbox/message-list reconciliation check and no timer boundingturn.heldEnd(unlike the bounded hold added for Antigravity in fix(antigravity): bound silent post-settle background command holds #40858).
Interrupting the stuck thread proves the exact state:
POST /api/session/<sid>/interruptreturns HTTP 200 withinterrupted: false(OpenCode is already idle).OpenCode2Adapter.interruptTurntakes its!reply.value.interrupted && state.active === turn && turn.heldEnd !== undefinedbranch.finishTurnmovesturn.steersintostate.strandedSteersandcancelStrandedSteerssendsDELETE /api/session/<sid>/inbox/<inboxID>for the two stale delegated-completion steer IDs — both return404 Not Foundbecause OpenCode had already delivered and removed them from its inbox.
Impact
Major degradation or frequent failure
Version or commit
v0.1.12-nightly.20261122.5098 (also checked 5098...5111 diff; no OpenCode2Adapter changes)
Environment
Linux x64 (Bazzite / Fedora Atomic), T3 Code Nightly desktop app (v0.1.12-nightly.20261122.5098), OpenCode 2.3.2, model opencode-go/deepseek-v4.1-flash.
Logs or stack traces
# 1) Back-to-back delegated-completion steers during active turn (UTC):
01:28:33.900Z OpenCode2Adapter.steerTurn -> POST /api/session/<sid>/prompt (2990ms, 200) # ordinal:4
01:28:37.061Z OpenCode2Adapter.steerTurn -> POST /api/session/<sid>/prompt (7.8ms, 200) # ordinal:5
01:29:16.769Z OpenCode2Adapter.steerTurn -> POST /api/session/<sid>/prompt (38.8ms, 200) # ordinal:6 (cleared normally)
# 2) OpenCode finished cleanly (confirmed via OpenCode plugin event subscription):
01:30:10.761Z final assistant turn-item.updated written to T3
01:30:10.782Z OpenCode emitted session.execution.succeeded (session now idle)
# Thread remained status="running", activeRunId!=null for 15+ minutes until manually interrupted.
# 3) Interrupt trace proving turn.heldEnd was set and both stale steers were already gone from OpenCode's inbox:
01:45:14.801Z POST /api/session/<sid>/interrupt -> 200 (interrupted: false)
01:45:15.357Z DELETE /api/session/<sid>/inbox/msg_t3_steer_<sid>%3Amessage%3Athread%3A<tid>%3Aordinal%3A4%3A<uuid> -> 404
01:45:15.452Z DELETE /api/session/<sid>/inbox/msg_t3_steer_<sid>%3Amessage%3Athread%3A<tid>%3Aordinal%3A5%3A<uuid> -> 404
01:45:14.800Z OpenCode2Adapter.interruptTurn -> Success (thread transitioned to interrupted)Workaround
Clicking Stop (t3_thread_interrupt) immediately hits the turn.heldEnd !== undefined branch in OpenCode2Adapter.interruptTurn, clears the stuck running state, and preserves the already-completed assistant reply.
Suggested fix: in endExecution (when end.status === "completed" and turn.steers.size > 0), check OpenCode's actual inbox/messages (or client.session.active() + inbox list) before holding turn.heldEnd indefinitely, and clear any steer IDs that are no longer pending in OpenCode's inbox.
Activity
juliusmarminge commentedon Nov 23, 2026
I tried to reproduce this on the current build and could not.
Commit b1ce608 (origin/main). Installed OpenCode 2.3.2 (npm @opencode/cli@2.3.2) in a scratch dir and pointed T3's OpenCode provider binaryPath at a wrapper that gives it isolated XDG data/state/cache dirs. Ran
T3CODE_DEV_SEED=0 vp run dev(fresh DB) and drove the web client in a browser with model Claude Haiku 5.5 via OpenCode. Run 1: prompt running twosleep 20bash calls; sent two steer messages back to back during the first sleep. Both showed as Steer, the agent answered 'DONE ALPHA BRAVO' and the thread completed. Run 2 (the reporter's path): agent used T3's delegate_task to start two background children (sleep 12 / sleep 14), then ransleep 25twice. Both children finished during the parent's sleeps, T3 steered their completions into the active OpenCode turn, the parent replied 'FINISHED' listing C1 and C2, and the thread settled (not stuck running). Runs 3 and 4 drove the OpenCode 2.3.2 HTTP API directly with T3-style steer ids (msg_t3_steer_:...): two back-to-back steers sent when the final step started streaming text, and again right as the final step ended. In both, OpenCode emitted session.inbox.enqueued and then session.inbox.delivered for every steer id, steer POSTs took 5-30 ms, and GET /inbox was empty afterwards. Not tried: the reporter's model opencode-go/deepseek-v4.1-flash, which the hub does not offer, and the reporter's 2990 ms steer POST latency, which suggests OpenCode was under load.Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
Realauster commentedon Nov 23, 2026
Thanks for testing this. Two details that explain why the quick repro did not hit it — and why the bug is still present in
b1ce608be3:Why the repro missed it:
ordinal:6, sent during a long-running shell tool call, 38.8 ms POST) did clear normally — matching your Run 2 (sleep 25).ordinal:4at 2990 ms right across a tool-failure/step boundary, followed immediately byordinal:5at 7.8 ms) arrived while OpenCode was transitioning between steps under load. Both were delivered to the model (confirmed in the model's subsequent reasoning and byDELETE /api/session/<sid>/inbox/<id>returning404for both on interrupt), yetturn.steersstill held both IDs whensession.execution.succeededarrived.The code-level bug is still in
b1ce608be3(packages/provider-opencode/src/server/v2/adapter.ts):endExecution(lines 3286–3292):goalHoldsTurn(state)right next to it already callsrefreshGoal(state)(withINVENTORY_TIMEOUT) because OpenCode can change goal state without notifying T3.turn.steers.size > 0, there is no equivalent reconciliation against OpenCode's inbox /client.message.list(even thoughbackfillat lines 3624–3628 already does this on SSE reconnect) and no timeout boundingturn.heldEnd. So any single missed/droppedsession.inbox.deliveredevent permanently wedges the thread inrunninguntil manual Stop.OpenCode2AdapterV2.test.ts): callsteerTurn, omitsession.inbox.delivered(while the steer message is already present inmessage.list/ absent from inbox), then emitsession.execution.succeeded— the turn staysrunningforever.Version:
v0.1.12-nightly.20261122.5098(confirmed identicalendExecution/turn.heldEndlogic onb1ce608be3). Could this be reopened to add inbox/message reconciliation (or a bounded hold) inendExecutionwhenturn.steers.size > 0?vtsixthai commentedon Nov 24, 2026
Independent confirmation from a different install: same model family on different builds, plus a second model family. Taking the close comment at its word and replying here with the exact steps and the version, since the follow-up above already covers the code side. Keeping to our evidence.
Version and environment. T3 Code v0.1.11 release, Linux x64 headless server, background service; the parent thread runs on Claude and drives OpenCode children through
delegate_taskandt3_thread_send. OpenCode 2.4.0 for the case below; the seven earlier occurrences ran OpenCode 2.3.2 on v0.1.10 and v0.1.11. Child models:deepseek-v4.1-flashin 5 cases,muse-spark-1.3-contributorin 3, so this is not tied to one model.Steps, as observed. The failure is intermittent here (5 stalls in 76 delegated OpenCode/DeepSeek threads over four days), so this is the observed sequence rather than a deterministic script:
steerTurndelivers them as inbox prompts withdelivery: "steer". OpenCode consumes each one, leaving a user message whose id equals the steer prompt id, and the inbox ends up empty.finish=stop) and the session goesidlewithoutcome=succeeded.runningforever. A queued successor run never starts and no wake reaches the parent, until someone presses Stop.Longest case (UTC, v0.1.11, OpenCode 2.4.0).
idle succeededthe same second.runningat 01:38:12 the next day, 326 min after OpenCode finished. A run 3 requested at 19:52:59 never started (startedAtnull) and was cancelled by the same interrupt.turn.heldEndbranch (L5300):Could not take back an OpenCode steerwith causeStatusCode error (404 DELETE /api/session/<sid>/inbox/<id>). A 404 here means the steer had been delivered 5 h 53 m earlier and OpenCode no longer held it.The same footprint in all eight cases. The service log holds exactly eight
Could not take back an OpenCode steerwarnings between Nov 21 and Nov 24, each with a 404 DELETE cause and a stack throughOpenCode2Adapter.interruptTurn, each on a different session: the five DeepSeek stalls (3.4, 146.7, 326.2, 950.8 and 963.6 min) plus threemuse-spark-1.3-contributorsiblings the same parents cleared in the same manual sweeps. In every case OpenCode's stored history ends with the final assistant message andidle succeededwell before the interrupt. Steering alone does not trigger it: 10 of 15 steered DeepSeek sessions completed normally, including some with 5, 7 and 9 steers, and 58 of 59 completed threads have T3 completion within 0.1 min of OpenCode idle. The trigger is the one missedsession.inbox.delivered, which also explains why the scripted repro above passes: healthy drains are instant, and the event has to be lost, which we cannot trigger on demand either.Still present on
mainatf981b42dc49(checked today,packages/provider-opencode/src/server/v2/adapter.ts):endExecution(L3342) parksturn.heldEndwheneverturn.steers.size > 0; the live prune is only thesession.inbox.cancelled/session.inbox.deliveredhandler (L3577) or a failed steer POST;backfill(L3662) already contains the authoritative check at L3686 (message.type === "user" && turn.steers.delete(message.id)) but only runs fromreconcileinsidereconnect(L3927, L3970). The goal hold parked by the same line already re-reads OpenCode state throughrefreshGoalbecause OpenCode can change state without notifying T3, and #40858 added a bounded hold for the analogous Antigravity case.What is not proven: why the event is missed in any given case. Candidates in the same file: events for a session with a running wake are buffered (
held.events.push, L3472) and only reachroutewhen a continuation replays them (replay, L4566), so a dropped wake drops its buffer; otherwise a plain SSE gap between heartbeats.Ask, same as the follow-up above plus one. Reconcile against authoritative OpenCode state before parking
turn.heldEnd(themessage.listcheckbackfillalready has, or the inbox listing), add a bounded settle timer as a backstop, and treat a 404 from steer take-back as "already delivered" instead of an ignorable warning; it is direct evidence the steer was consumed.Regression shape that would have caught this:
steerTurnwith the steer user message present in history andsession.inbox.deliveredsuppressed, plus a variant where it arrives late, after a wake buffer holds it, thensession.execution.succeeded; assert the turn completes, a queued successor starts, and the parent wakes. Our longest case also has anidlemarker withoutcome=failed("Execution was interrupted repeatedly") 7 s before the finalidle succeeded; only the succeeded marker should settle the turn.Collected and written by a Claude Opus agent at the owner's request, from read-only service logs, T3 thread projections and OpenCode storage on the affected server. Session, thread and task ids and local paths are redacted.
Realauster commentedon Nov 24, 2026
Thanks @vtsixthai for the independent confirmation and detailed logs across 8 cases, two model families (
deepseek-v4.1-flashandmuse-spark-1.3-contributor), and both OpenCode 2.3.2 and 2.4.0.We've had to keep a local workaround in place (ending OpenCode turns immediately after launching async delegates so completions don't arrive as mid-turn steers) while waiting on a fix.
@juliusmarminge — since two independent installs now show the exact same
404 DELETE /api/session/<sid>/inbox/<id>+ unboundedturn.heldEndstall onmain(f981b42dc49), could this issue be reopened to add inbox/message reconciliation and a bounded settle timer inendExecution?