Skip to content

[Bug]: Delegated-task subagent records stay running after the child finished, so the parent lists as waiting forever #37090

Closed as not planned

Description

@zikaclawbot

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

I can't trigger the bad state on demand. This is what I observed and how to check for it.

  1. On 0.0.46 nightlies (20261013.3053 to 20261015.3145), a parent thread sent follow-up work to existing delegate_task children with t3_thread_send. Seven of the 306 app-owned subagent records created that way on this machine ended up stuck. All seven date from 2026-10-13 to 2026-10-15, and none of the later ones did. One was created about three minutes after the desktop app restarted to install an upgrade.
  2. Keep using the app through many restarts and upgrades, up to 0.1.10-nightly.20261113.4656.
  3. Run t3 thread list --json --project <id> for the parent's project.

Expected behavior

When a delegated child's run ends, its subagent record leaves running. If that transition was missed, startup reconciles it. A thread whose delegated work has all finished lists with its own status, not as waiting.

Actual behavior

The parent has no active run and was settled a month ago, but thread list still lists it as waiting. Its pendingBackgroundTasks holds one subagent task. As far as I can tell from the server bundle, listedThreadStatus returns waiting because backgroundWorkHoldsCompletion treats that task as pending: its record's status is still running, which isOrchestrationV2WorkActive counts as active.

The record in orchestration_v2_projection_subagents:

  • origin is app_owned and status is running.
  • started_at equals updated_at (2026-10-13), and completed_at and result are null.
  • completion_delivery_state is pending on three of the stuck records and acknowledged on the other four.

The child the record points to is finished. t3 thread show --json <child> returns status: completed and activeRunId: null, and its last run completed the next day. That child has two stuck records of its own, and their grandchildren are completed too.

None of this changed over a month of restarts and upgrades.

Impact

Minor bug or occasional failure

Anything that waits for every thread to be idle before restarting T3 Code waits forever. We restart T3 Code to apply nightly updates only when no thread is busy, and one stuck record blocked every night's update.

Version or commit

The records were created on 0.0.46-nightly.20261013.3053 to 0.0.46-nightly.20261015.3145. They are still unreconciled on 0.1.10-nightly.20261113.4656.

Environment

Linux (Arch based), desktop app from the AUR package t3code-nightly-bin. The parent ran on Codex. The children ran on Codex and Claude.

Logs or stack traces

# read-only query on userdata/statev2.sqlite
origin     status   started_at                updated_at                completed_at  completion_delivery_state
app_owned  running  2026-10-13T12:52:37.170Z  2026-10-13T12:52:37.170Z  NULL          pending

# t3 thread show --json <childThreadId of that record>
status: completed   activeRunId: null   latest run completed 2026-10-14T06:31:21Z

# t3 thread list --json (parent)
status: waiting   settled: true   pendingBackgroundTasks: [{kind: subagent, childThreadId: <that child>}]

Workaround

I haven't found one that leaves the state alone. Our idle check no longer trusts waiting. It now asks thread show whether each child named by a pending task has runs of its own and has settled.

Related: #28448. There a completion is never delivered to the parent. Here the record itself never leaves running.

Activity

  1. juliusmarminge commented on Nov 15, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit: origin/main 2dc5ebd. Traced the stuck state to pre-#19019 builds: before afc12ab (fix(server): a steered send no longer leaves a subagent task running, #19019, merged 2026-10-18), recordSubagentFollowup created a new app-owned follow-up subagent record for a t3_thread_send steered into a running child attempt. The steer never tagged a child run with that task's delegatedTaskId, so the record could never settle. This matches the reporter's 2026-10-13..15 window and the fact that no later record got stuck. On main I wrote a server-level test in apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts ('recovery settles a follow-up task no child run owns once its child finished'). It seeds that legacy state through the EventSink: a settled parent; an original task that completed and was delivered; a follow-up task with status running, result null and completionDelivery pending, plus its running subagent turn item; and a child thread whose two runs both completed, neither tagged with the follow-up's id. It then runs orchestrator.recoverDelegatedTasks, the startup reconciliation. Run with vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts -t "no child run owns" from apps/server. Result: the follow-up task stays 'running', and the parent shell's pendingBackgroundTasks still holds the subagent task for that child; each assertion fails on its own. That pending task is what makes the MCP thread list report 'waiting'. I did not run the full app: the legacy state only comes from a pre-#19019 build with a real provider that takes a steered message mid-turn. No such provider was available on this VM, and the free Replay provider did not exist in those builds.

    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.

  2. AryanRG commented on Nov 27, 2026

    @AryanRG

    Observed on T3 Code Nightly, server 0.1.14-nightly.20261127.5319, on macOS desktop. A Claude provider thread sent follow-ups with t3_thread_send after a delegated child thread (codex provider) had finished. Three app-owned follow-up records remained waiting with completion_delivery_state = 'pending' after the child finished again. Other follow-ups settled. The parent showed Working and its Lineage panel showed the child as running or waiting for about three days. Restarts and archiving or unarchiving the child did not clear it.

    The stale records appeared in orchestration_v2_projection_subagents and the matching subagent rows in orchestration_v2_projection_nodes. task_status reported status: completed and workState: result_available for the affected tasks. task_cancel changed delivery to disposed but left the status waiting. The relevant orchestration_v2_events had already been pruned. Correcting the rows to completed cleared the live nodes on the server.

    The trigger was intermittent. A settlement sweep that checks app-owned follow-up records against the child's live runs would let the server recover even after the completion event has been pruned.

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