Skip to content

[Bug]: Remote delegated-task completion can revert a finished parent run to waiting and deadlock the thread (#20014's fix misses this path) #29860

Open

Description

@jamesdchen

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

Summary

#20014 is back through a path its fix didn't cover. #20025 stopped delegated-task finalization from writing a stale parent run, but only for local tasks. dispatchRemoteDelegatedTaskComplete still writes the full parent-run snapshot it read earlier. A task delegated to a linked environment that finishes during the parent's checkpoint capture can therefore return the parent to waiting for good. Its own completion notice and every later message then queue behind that run.

Steps to reproduce

This depends on timing. I hit it once in normal use and haven't reproduced it deterministically.

  1. On a local Claude thread, use delegate_task with target.environmentId set to a linked environment. A child that finishes quickly helps.
  2. End the parent turn so that checkpoint capture starts.
  3. Have the remote child's completion arrive during capture. The race window is between dispatchRemoteDelegatedTaskComplete reading the parent run and its events being written, with the capture commit landing in between.

The regression test from #20025 forces this ordering for local tasks, and the same technique should work with delegated_task.remote.complete.

Expected behavior

The parent run stays completed with its completedAt and checkpointId, and the completion notice starts as a new run.

Actual behavior

The parent run stays waiting with completedAt: null and checkpointId: null, although its provider turn is completed and its capture succeeded. Nothing moves it out of that state, so all queued runs stay blocked. In my case that lasted from 01:36 UTC until I stopped waiting about 40 minutes later, and the run is still stuck.

Timeline for the affected run, all times UTC on 2026-11-03:

Time Event Source
01:36:05.430 Provider turn completes provider_turns
01:36:05.748 checkpoint.capture effect created outbox
01:36:05.802 Checkpoint captured_at checkpoints
01:36:06.917 Remote child's task completes subagents
01:36:07.400 checkpoint.capture effect succeeded outbox
01:36:09.533 Completion notice queued as the next run, delegatedCompletion.generation: 1, parent = stuck run messages

State afterwards:

  • The stuck run has status: waiting, completedAt: null, checkpointId: null. The two runs before it on the same thread are completed with both fields set.
  • The cohort's nextGeneration is 2, so the remote completion did take a planDelegatedCompletionDelivery branch that returns {...input.parentRun, delegatedCompletion}.
  • There are no open nodes, runtime requests or provider turns for the run, and pendingBackgroundTasks is empty.

What this doesn't prove: this install's event log has been compacted and the server trace for 01:36 has rotated out, so I can't show the run.updated order directly. The stale write is inferred from the state and timing above, plus the code below.

Recovery attempts on the stuck run all failed:

Cause

Line numbers are from main at e1e520c93c99, and the same logic is in the v0.1.6 server bundle.

  • Orchestrator.ts:12613: the local path writes with { updateDelegatedCompletionOnly: true }, which is the fix(server): delegated completions preserve finished parent runs #20025 fix.
  • Orchestrator.ts:8292-8301: the remote path emits run.updated with payload: plan.parentRun, a full row built from the projection it read at the start of the dispatch.
  • Orchestrator.ts:13348-13350: the delegated_task.remote.complete case doesn't set updateDelegatedCompletionOnlyRunId, which the delegated_task.completion-delivery.* cases do.
  • ProjectionStore.ts:723: preserveRunRecordedFields doesn't protect status, completedAt or checkpointId.

A likely fix is to return the parent run id from dispatchRemoteDelegatedTaskComplete and set updateDelegatedCompletionOnlyRunId from it, as the completion-delivery commands do.

Impact

Major degradation. The thread can't take any input, and I found no way to clear it from the UI or MCP tools. A comment on #20014 reports that a server restart recovers this state; I haven't tried that here yet.

Version or commit

v0.1.6

Environment

Windows 11 desktop app. Parent on the Claude provider (claude-opus-5-5). Remote child on a linked Linux environment running v0.1.6, using the Kimi CLI ACP provider, reached through T3 Connect.

Related

Activity

  1. a2lxyz commented on Nov 13, 2026

    @a2lxyz

    Hit this on 0.1.9 (Linux server, Claude provider), matching the description exactly: a task delegated with delegate_task to a linked environment finished about 1 s after the parent's turn ended.

    What the projection showed (statev2, read-only):

    • Parent run: status: "waiting", completedAt: null, checkpointId: null. Its attempt is completed, there are no pending runtime requests, and delegatedCompletion: { disposition: "open", delivery: { generation: 1, messageId: …, taskIds: [<remote task>] } }.
    • The delivery message's run is queued behind the parent, with every later message queued after it. startNextQueuedRun returns early because isActiveRun$1 counts waiting as active, so nothing ever starts.

    Every way out is refused:

    • run.interrupt fails with Run … is not interruptible. The thread's activeProviderThreadId / the run's providerThreadId is a native-thread:pending%3Arun%3A…%3Aordinal%3A1 placeholder that isn't in projection.providerThreads, so the providerThread === void 0 guard throws. That seems to make interrupt fail for this thread in general, not only for the wedged run (cf. [Bug]: Stop can't end background work after a run fails before its provider starts ("Run … is not interruptible") #15472).
    • Queue promote_to_steer and reorder refuse automatic completion deliveries ("cannot be promoted to Steer", "cannot be reordered").
    • Archiving would cancel the whole queue.

    Workaround that worked without losing messages:

    1. Back up statev2.
    2. Restart the server. Startup recovery cancels the waiting run and marks the queue queueHeld: true; runs cut on other threads resume.
    3. Send the thread one message. It starts at once, and when it completes the held queue drains in order, including the delivery.

    The cost is that the restart cuts every other in-flight turn on that server. A narrower recovery (e.g. treating a waiting run whose attempt is completed and whose only open delivery is queued behind it as completed) would avoid that. We're running a detector for this condition until a release with the fix lands; happy to test a nightly.

  2. andrewgeorgemitchell commented on Nov 19, 2026

    @andrewgeorgemitchell

    Hit this on 0.1.10 (macOS desktop app, stable channel), on the same path. A Claude parent (claude-opus-5-5) used delegate_task with a target on a linked Linux environment (Codex child) and ended its turn. The remote result landed inside the parent's checkpoint capture. The thread has been wedged for over 85 minutes, with 29 runs queued behind it.

    This may help with the repro that stopped #29882 ("could not show the problem on the base commit"): the capture here was slow. It took 12.5 s, against about 1 s for the same thread's two previous captures, and the remote result was applied 0.34 s before the capture committed. In the original report the capture took 1.65 s. With a fresh data directory and a small worktree, the capture probably finishes before a real remote round trip can land inside it. A large worktree, or anything else that slows checkpoint.capture, should make the race much easier to hit.

    Timeline, UTC on 2026-11-19, read-only from statev2:

    Time Event Source
    04:16:18.346 delegate_task returns, remote child running turn item
    04:16:29.782 Remote child's run completes (linked server's clock) child thread run
    04:16:31.496 checkpoint.capture effect created outbox
    04:16:31.517 Checkpoint captured_at, status ready; root node completed checkpoints, nodes
    04:16:43.651 Remote result applied: subagent node and row completed nodes, subagents
    04:16:43.989 checkpoint.capture effect succeeded outbox
    05:36:37 Stop pressed: run_interrupt_request item recorded, run unchanged turn items
    05:36:49 / 05:36:50 Two delegated-tasks.stop effects: one succeeded after 4 attempts, one failed after 5 (OrchestrationEffectExecutionError with an empty message) outbox

    State afterwards:

    • The parent run has status: "waiting", completedAt: null and checkpointId: null, although its checkpoint row exists and every node of the run is completed.
    • delegatedCompletion is { disposition: "stopped", nextGeneration: 2, delivery: null }. This is after the Stop.
    • The subagent row is completed, with completion_delivery_state: disposed.
    • It is the only waiting run on the server. The thread has 29 queued runs, none of them held. There are no pending requests and no background tasks.

    This has the same limits as the original report. The v2 event log is compacted (orchestration_v2_events is empty), and the server trace rotated out within about 20 minutes, so I can't show the run.updated order directly. Against the v0.1.10 tag, the delegated_task.remote.complete case (Orchestrator.ts:15309) still sets no updateDelegatedCompletionOnlyRunId, so #29882 still applies.

    Filed by Claude Code (claude-opus-5-5), following .github/triage/PLAYBOOK.md.

  3. jndegens commented on Nov 19, 2026

    @jndegens

    Hit this on 0.1.9 (Linux server, Claude provider), same path: the parent used delegate_task with a target on a linked macOS environment. The remote child failed on a usage limit, a retry child completed about 1.5 h later, and the parent run has been waiting since 2026-11-17 14:23 UTC (about 54 h). Two completion notices plus two later messages were queued behind it.

    Things that did not unwedge it, in case it helps whoever picks up #29882:

    • t3_thread_interrupt with the runId → Run … is not interruptible. (dispatchRunInterrupt finds no running provider turn for a waiting run).
    • t3_thread_interrupt with stop: true → no_active_run, but the queue does become held (queueHeld: true), so the run stays waiting and the queue is now paused too.
    • queued-run.start is refused for the completion notice because its message carries delegatedCompletion, and startNextQueuedRun bails while any run is waiting (isActiveRun$1).

    What worked: a graceful server restart (SIGTERM). ProviderRuntimeRecoveryService.reconcileProjection cancelled the waiting run ("server shut down before the provider work completed"). The remaining queued runs were still queueHeld: true from the earlier Stop, so they need Resume in the UI afterwards. Without the Stop attempt first, a restart alone is probably enough.

  4. TheOriginalOcyrus commented on Nov 22, 2026

    @TheOriginalOcyrus

    Also hit on 0.1.11 (macOS, t3 serve as a launchd daemon, Claude parent on claude-opus-5-5). One variation: no delegate_task call in that turn started the remote child. The parent sent t3_thread_send to an existing delegated thread on a linked environment, and T3 tracked it as a remote-followup task under the parent's run.

    Timeline, UTC on 2026-11-22, from the thread's items and the provider event log:

    Time Event
    16:06:53.59 Provider turn ends (result, end_turn)
    16:06:55.82 Checkpoint item for the run
    16:06:59.27 The remote follow-up's result lands in the run
    16:36:53.63 Idle provider session closed (query.close)

    After that the run stayed waiting with completedAt: null. It had no open nodes and no runtime requests, pendingBackgroundTasks was empty, and delegatedCompletion.nextGeneration was 2. 50 runs queued behind it for 2 h 37 min.

    Two things not yet in this thread:

    • Stop on the wedged parent also stops the parent's other remote delegates. Stop in the UI didn't free the run. But the server trace shows it dispatched delegated_task.remote.stop for about 7 of the parent's other delegated tasks on the linked environment, so live children there were cut off.
    • After the restart, one new message started the held queue. The SIGTERM restart cancelled the waiting run, as described above. The queue stayed idle, since Stop and t3_thread_interrupt with stop: true had held it. A single t3_thread_send with mode: "auto" started a run, and the queued runs drained after it with no Resume.

    Still unfixed in 0.1.11; #29882 would fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions