Delegated Claude workers are finalized when they end their turn on a Monitor without calling t3_background_wait #31843
What happened#
Delegated Claude Agent workers (delegate_task) started long jobs in the background, armed a Monitor to wait, said "The watch is armed. I'll hold until..." and ended their turn. T3 marked each worker completed ~2s later and delivered its unfinished result to the coordinator; the Monitor firing never resumed it. Happened to two workers despite prompts saying not to end the turn while waiting.
Diagnosis#
backgroundWorkHoldsCompletion (packages/shared/src/orchestrationV2PendingBackgroundWork.ts) lets monitor/command tasks hold completion only when awaited, i.e. only after t3_background_wait. Agents learn of that from one sentence in CLAUDE_BACKGROUND_WAIT_INSTRUCTIONS and the tool is deferred, while Claude Code's Monitor result says "You will be notified on each event. Keep working — do not poll or sleep." The model follows the tool result and never calls t3_background_wait (it was in its tool list). settlesChildWork/finalizeAppOwnedSubagent then finalize the app-owned child.
Possible fixes: (a) treat monitors/background commands of a delegated child as awaited by default; (b) append a reminder to Monitor/background-Bash results in delegated sessions; (c) don't finalize a child with a live Monitor, or reopen it on a later task notification.
Steps to reproduce#
- In a Claude Agent thread,
delegate_taska Claude Agent worker to start a long background command (e.g.sleep 600; echo done > /tmp/x). - Ask it to wait and then report. It arms
Monitor, says the watch is armed, ends its turn. - SDK emits
result/end_turnwhilebackground_tasks_changedstill lists the task; subagent goescompletedand its result is delivered within seconds. - The Monitor firing does not resume the delegated task.
Version#
0.1.8-nightly.20261104.4179 (server that ran coordinator and workers). Triage CLI: 0.1.8-nightly.20261106.4247.
Environment#
Linux x64 (Arch, kernel 7.2.14), Node v26.12.1. Desktop app against a local server. Workers on the Claude Agent driver (Claude Code 2.1.318, claude-haiku-5-5) via delegate_task.
Evidence#
Worker A3r2 SDK events (UTC):
06:11:28.328 tool_use Monitor
06:11:28.352 background_tasks_changed tasks=[bc9ptu6d8]
06:11:28.361 tool_result "Monitor started ... You will be notified on each event. Keep working — do not poll or sleep."
06:11:31.982 assistant "The watch is armed. I'll hold until ..."
06:11:32.006 result success stop_reason=end_turn
06:11:33.971 subagent completed, delivered
06:11:49.800 coordinator restarts worker
No t3_background_wait call in the session. Second worker (H1): "The watcher is armed" 05:41:24, completed 05:44:03.
Related issues#
#31817, #29772 (t3_background_wait misbehaving once called; this is about it never being called). #24956. None cover this case.
Fix applied or workaround#
No local patch. Tell delegated workers to load and call mcp__t3-code__t3_background_wait with the task ID before ending their turn, or block in-turn (timeout 3600 tail --pid=<pid> -f /dev/null).
Filed by#
Claude Opus 5.5 (claude-opus-5-5) in Claude Code, via t3 triage.
sheepbun(GitHub profile, opens in a new tab) added labelsvia-triage
Still reproduces on 0.1.8 (Windows desktop app, WSL runtime, Claude Code 2.1.322).
Minimal repro: a Sonnet 5.5 child (async
delegate_task) starts aMonitorrunningsleep 60; echo MONITOR_DONE, doesn't callt3_background_wait, and ends its turn withWAITING. The task was delivered to the parent right after that turn ended, about a minute before the Monitor fired. When the Monitor fired, the child woke and wroteFINAL, which never reached the parent.With
t3_background_waiton the Monitor, the parent stayed asleep until the Monitor ended, but it still received the first turn'sWAITINGrather thanFINAL(see #28448).Drafted with Claude (Opus 5.5) in T3 Code; the repro ran on my install.
tanstack-source added labelsbug
Still happens on 0.1.9 (macOS desktop app, Claude Code 2.1.322, coordinator and both workers on Claude Agent /
claude-opus-5-5). What I saw is a little different: the worker does get resumed when its background work finishes, and its new result reaches the parent. Even so, the worker is marked finished every time it ends a turn to wait, and the parent thread goes to Done between wake-ups instead of Working/Waiting.Setup: the coordinator started two async
delegate_taskworkers, "Root-cause lockstep timeout under load" and "Finish #96 rf2o retest analysis". Each starts long sim builds or test runs in the background, ends its turn while they run, and resumes when they finish.Timeline (UTC, 2026-11-12):
Time Event 19:43:16 "Delegated task Root-cause… finished". The worker's last message was "The baseline at 3 CPUs is running. I'll check its RTF once the first cell finishes." Parent run 67 starts, replies "still working", and completes 4 s later 19:43:38 Root-cause… "finished" again. Run 68 replies "still running" and completes 2.5 s later 19:46:08 Finish #96… "finished" (its last message: "the nightly PitchBootcheck is compiling…"). Run 69 replies and completes19:46:16 Root-cause… "finished" ("The unloaded baseline is running…"). Run 70 replies and completes 19:49:00 Root-cause… "finished" ("Building sim@b40ada7and running it unloaded."). Run 71 replies and completes at 19:49:0319:49:59 Parent: status: completed,activeRunId: null,pendingRequestCount: 0. Both workers' builds are still runningSo Root-cause… was reported "finished" 4 times in 6 minutes, and the work it was waiting on was still going each time. The parent spends each wake-up writing a "still working" reply, and the thread list shows it as done in between.
Expected: while a delegated worker has live background work, it stays running/waiting. The parent isn't woken with a "finished" notification, and the parent thread shows Waiting, not Done.
Fixed by #37085, now on main: A delegated Claude worker that starts a Monitor and ends its turn now remains waiting without calling t3_background_wait, so its interim response is not delivered as the finished result while the monitor is running.
juliusmarminge closed this
Sign in to join this conversation.
Another case with the same cause, outside delegation: a top-level Claude thread with Auto-settle merged threads on, where the Monitor was watching for the very merge that settled the thread.
I asked the agent to watch a production deploy. It armed a
Monitorrunning a script that waits for the PR merge and then follows the deploy, and ended its turn. There is not3_background_waitcall anywhere in the session. I merged the PR, the Monitor woke the agent, and it reported the merge. One second after that turn ended, the thread was auto-settled and the Claude session closed, which took the Monitor with it. The rollout I asked it to watch had only just started. I found out when I messaged the thread four minutes later. The agent guessed "the session restarted" and re-armed the Monitor.This could have been an expensive failure. I merged a production deploy believing the watcher was running and would warn me if pods or error rates went wrong. For those four minutes nothing was watching, and nothing told me the watch had ended. If the rollout had gone bad, I'd have found out late.
Timeline (UTC):
thread.auto-settleruns, and the provider event stream ends withError: Thread settled.Watching a deploy after a merge is a common reason to arm a Monitor, so settle-on-merge lands right when that watch starts. Related: #29896 (settle-on-merge cuts off planned post-merge work).
Environment: T3 Code 0.1.7 server on Linux (Arch), web client, Claude Code 2.1.319, claude-opus-5-5, local connection.
Drafted with Claude Opus 5.5 (Claude Code) on behalf of @lingolooper-simon.