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?