delegate_task fails with parent_not_active when a Claude wake turn runs before T3 opens its run #33272
Version#
T3 Nightly 0.1.7-nightly.20261102.4093 (Linux x64). Thread provider: Claude Agent SDK, bypassPermissions.
What happens#
A lead thread starts a background command (Claude Code run_in_background) and its turn ends. When the command finishes, the Claude Agent SDK starts a native wake turn on its own (task-notification origin). The model acts in that turn and calls the T3 MCP tool delegate_task, which returns:
{"_tag":"OrchestratorMcpFailure","code":"parent_not_active","message":"Delegated tasks require an active run owned by this MCP provider session."}
The same call works in turns T3 started itself.
Timeline (one real case, UTC, 9 Nov 2026)#
| Time | Event |
|---|---|
| 08:25:32.75 | Run 96 completes (checkpoint captured). The thread has no active run. |
| 08:27:35.196 | Background command ends. The adapter detects the wake turn and offers a provider continuation. message.dispatch for it begins; requestedAt/message createdAt are stamped here (now$34). |
| 08:28:03.3, 08:28:08.1 | Inside the native wake turn the model calls mcp__t3-code__delegate_task twice. Both return parent_not_active. |
| 08:28:28.660 | The dispatch for run 97 finally commits (its provider-turn.start effect is created with the provider-continuation command id). |
| 08:28:30.6 / 08:28:31.0 | Run 97 attempt and provider turn start. The native wake turn has already finished, so the buffered frames replay and the turn completes in 0.5 s. |
Run 97 took 55.4 s from request to start. Every other provider-continuation run that day started in 0.1 to 3.3 s. In the same window a queued run on an unrelated thread (another instance) waited 83 s after its predecessor completed at 08:27:08.8, so the orchestrator was slow server-wide. The heap-spike trace at 08:27:02 names Orchestrator.handleRunUpdate and Orchestrator.finalizeAppOwnedSubagent as suspects.
Root cause#
A Claude native wake turn runs (and executes MCP tools) before the orchestrator has committed a run for it. Run-scoped MCP tools only look at committed runs, so for the whole gap the thread looks idle to them. Normally the gap is under a second. Any orchestrator slowdown stretches it, and every run-scoped tool call made in the wake turn fails.
Code (line numbers in the embedded server bundle, the same numbering T3's own stack traces use):
src/mcp/OrchestratorMcpService.ts,delegateTask, t3:425785-425786:const parentRun = parent.runs.filter(isActiveRun)...[0]; if (parentRun === void 0 || ...) return failure("parent_not_active", ...). At 08:28:03 the projection held run 96 (completed) and no run 97, soparentRunwas undefined.- Same check in
src/peer/RemoteDelegation.tst3:424290 andPeerLinkRequests.request(t3:395246,t3_environment_link). src/orchestration-v2/Adapters/ClaudeAdapterV2.tst3:280040-280068: the wake turn is detected and a continuation is offered, but the native turn is not held. Frames are buffered for replay while the SDK keeps executing tools.src/orchestration-v2/ProviderContinuationService.tst3:384684-384700: the continuation becomes amessage.dispatch(queue_after_active,creationSource: "provider"), and that run is what the MCP check needs.canUseToolcan't gate the wake turn under bypassPermissions (the SDK warnsCLAUDE_SDK_CAN_USE_TOOL_SHADOWEDin the server log).
Expected#
A tool call made inside a provider-initiated wake turn is owned by that wake turn's run, the same as in a T3-started turn.
Suggested fix#
- In the run-ownership check shared by
delegateTask,RemoteDelegation.delegateandPeerLinkRequests.request: when there is no active run but this provider session has a pending continuation (a requested continuation in the adapter, or a queued or starting run whose user message hascreationSource: "provider"), wait for that run to commit and become active (bounded, for example 60 s), then bind to it instead of failing. - Or hold the wake turn's tool execution in the Claude adapter until the continuation run attaches, using a PreToolUse hook (not
canUseTool, which bypassPermissions skips). - Separately, find the server-wide stall from 08:27:08 to 08:28:28 UTC that held this dispatch for 53 s.
Test: start a Claude thread, have it run a background command and end its turn. When the command finishes, have the wake turn call delegate_task, with the orchestrator dispatch for the continuation artificially delayed (for example a held thread dispatch lock). The call should succeed and the child should be parented to the continuation run.
tanstack-source added labelsbug
Sign in to join this conversation.
Note
Written by Claude Opus 5.5 on behalf of @WhiteWarrior625
A related case on Codex,
0.1.10-nightly.20261116.4787(Linux AppImage), where the run had started and T3 still refused writes.A delegated Codex thread was resumed by a provider-continuation run (
delegatedTaskId: node:delegated-task:provider-continuation:...), after two earlier runs had failed because background work was still running. The run started at 23:36:09 UTC and completed at 23:42:00. During it:t3_thread_read/t3_thread_listworked, and the thread detail reportedactiveRunId= that run,status: running,providerInstanceId: codex.parent_not_active("The calling provider no longer owns an active thread run."):t3_thread_sendat 23:38:09 and 23:38:34,t3_thread_organizeat 23:41:03. Writes from the same thread had worked at 22:13 to 22:27 on ordinary runs.listThreadsuses) showedactiveRunId: null. Right after the run it showedstatus: completed,latestRunId= that run.The write gate and the read path use different sources.
assertLiveCaller→isLiveCallerShell(shell, providerInstanceId)checksshell.activeRunId !== null, whilethreadDetailderivesactiveRunIdfromlatestActiveRun(projection). For this provider-continuation run the run projection was right and the shell'sactiveRunIdnever got set, so the live caller was refused for the whole run.We work around it locally by having
assertLiveCallerfall back to the run projection when the shell shows no active run. It allows the call only for an unarchived caller thread on the caller's provider instance that has a run inpreparing/starting/running/waitingon that instance (getThreadRecords(id, ["runs"])), and otherwise refuses as before. The cleaner upstream fix is probably to set the shell'sactiveRunIdwhen a provider-continuation run starts, or to have the gate read the same source asthreadDetail.