Repository navigation
Description
What happened
An orchestrating agent launches Codex threads over MCP with t3_thread_launch (workspaceStrategy: { type: "worktree", baseRef: "origin/main", startFromOrigin: true }, no initial message), then sends the brief with t3_thread_send. Four such threads stayed running for hours. Every later message queued behind run 1 and never started. Codex had in fact finished each turn within 5 to 10 minutes, but T3 never recorded it.
Diagnosis
A message-less t3_thread_launch returns before worktree preparation finishes, while worktreePath is still null. In ThreadLaunchService.launch, runId is null, so schedulePreparation runs in the background. The t3_thread_send that follows dispatches a normal message. Nothing marks the thread as still preparing, so run 1 starts at once on the shared Codex app-server, with cwd set to the project root.
About 2 s later, preparation dispatches thread.metadata.update with the new worktreePath (${commandId}:workspace). In Orchestrator.ts, a worktreePath change puts every live provider session into detachSessionIds and queues provider-session.detach ("Workspace changed."). That path never checks for an active run. provider.switch and thread.model-selection.set do check, and they reject with OrchestratorProviderSelectionBusyError.
The detach effect runs right after provider-turn.start settles. ProviderSessionManager.detach looks for running provider turns to interrupt and finds none, because the turn has only just started. It then calls CodexAdapterV2.unloadThread, which sends thread/unsubscribe 10 ms after turn/started. After unsubscribe, the connection never receives turn/completed. unloadThread finalizes only turns that are already being interrupted, so the T3 run stays running permanently.
Side effect: the agent ran the whole turn in the main checkout, not in the worktree bound to the thread.
The same code is still on main (Orchestrator.ts, the detachSessionIds branch for thread.metadata.update).
Steps to reproduce
- Use any git project with the Codex provider. The shared app-server session is the default.
- Over MCP, call
t3_thread_launchwith a Codex model,workspaceStrategy: { type: "worktree" }and noinitialMessage. - As soon as it returns, before
t3_thread_readshows a non-nullworktreePath, callt3_thread_sendwith any prompt that takes more than a few seconds. - Expected: the run executes in the worktree, or waits for it, and completes. Actual: the provider event log shows
turn/startwith the project root ascwd, thenthread/unsubscriberight afterturn/started. The thread staysrunningand later messages queue forever.
Threads launched with workspace root (no worktree) on the same server complete normally. Their only thread/unsubscribe is the idle unload about 30 minutes after turn/completed.
Version
0.1.14-nightly.20261127.5319 (desktop app with its bundled local server; commit ee5b846)
Environment
Windows 11 x64 (10.0.26300), Node v24.22.1, codex-cli 0.172.0, desktop app against local server
Evidence
# provider event log of one affected thread (UTC)
04:02:46.823Z outgoing thread/start cwd=<home>\projects\xbot-dashboard # project root, not the worktree
04:02:50.582Z outgoing turn/start cwd=<home>\projects\xbot-dashboard
04:02:50.611Z incoming turn/started turn 01a21b2b-9458-...
04:02:50.621Z outgoing thread/unsubscribe {threadId: 01a21b2b-85ae-...}
04:02:50.622Z incoming {result: {status: "unsubscribed"}}
04:12:26.643Z incoming thread/readState/changed, thread/status/changed ... thread/closed # no turn/completed
# orchestration_v2_effect_outbox for the same thread
provider-turn.start created 04:02:46.786Z completed 04:02:50.608Z
provider-session.detach created 04:02:49.040Z completed 04:02:50.622Z detail="Workspace changed."
# projection run 1: status=running, startedAt=04:02:50.412Z, completedAt=null, no workspacePreparation
# thread: worktreePath=<home>\projects\worktrees\t3code\xbot-dashboard\t3-cecb386d-..., runs 2..5 queuedThe same sequence (provider-turn.start, then provider-session.detach "Workspace changed." about 1.5 s later, then unsubscribe 10 ms after turn/started) appears on all four affected threads, in three different repos.
Related issues
#35274 (Grok run stuck after t3_worktree_handoff) and #36086 (Codex native child stuck after thread/unsubscribe) end the same way: a turn whose completion never arrives after an unload. Neither has this trigger, a launch-time worktree bind racing an already-started run. #21953 is another workspace-change detach that cuts a run off.
Fix applied or workaround
Nothing was changed on the machine. Workaround for MCP callers: pass the brief as initialMessage to t3_thread_launch, so the run is created as preparing and starts only after the worktree is bound. Alternatively, poll t3_thread_read until worktreePath is non-null before calling t3_thread_send. Stuck threads can be archived or have run 1 interrupted.
Possible fixes: reject or defer a t3_thread_send while launch preparation is pending, and/or make the worktreePath-change detach refuse or wait when a run is active, as provider switching does.
Filed by
Claude Code (claude-opus-5-5) via t3 triage
Activity