Skip to content

[Bug]: A delegated task stays running and its parent is never woken when the parent's update for a failed child is dropped #37226

Closed

Description

@sungyongcho

Fix: #37225

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

Deterministic repro (regression test in the linked PR, apps/server/src/orchestration-v2/DelegatedChildTerminalRetry.test.ts):

  1. A parent thread calls delegate_task (completionWake: "always").
  2. The child's provider session cannot start: ensureThread fails, so the child run settles failed with "Provider turn failed to start".
  3. The parent's reaction to that terminal run.updated fails once on a projection read (the test injects one ProjectionStoreReadError into the read finalizeAppOwnedSubagent makes).
  4. The parent's turn ends.

Where I hit it: a Claude parent delegated an async task to Codex while the disk was out of inodes. Codex's thread/start failed with error creating thread ... No space left on device (os error 28).

Expected behavior

The parent's task row settles failed with the child's error, a subagent_result context transfer is written, and the parent is woken with the failure, as it is for any other failed child.

Actual behavior

The child run is failed, but the parent's task row stays running, and nothing retries it:

  • The parent is never woken. Its turn ended normally and it sat idle for about 2.5 hours until I noticed.
  • The sidebar shows the child as in progress, and its elapsed time keeps growing (it read 5.3 h and later 5.7 h).
  • task_status reports failed / result_available, because it derives the status from the child run when task.result is null, but resultContextTransferId is null.
  • task_cancel returns {"status":"failed"} and changes nothing. Settling or archiving the child thread does not clear the parent's row either.
  • Three other children (two OpenCode, one Antigravity) failed in the same window and were settled normally. Their results have context transfers.

Cause, from reading the code on main:

  • The parent learns about a child's terminal run only through handleRunUpdate in apps/server/src/orchestration-v2/Orchestrator.ts. It calls finalizeAppOwnedSubagent once per run.updated event (around line 15773).
  • If that call fails, the error is caught, logged as Failed to react to V2 run update, and dropped (around line 15784). The event is not delivered again.
  • The only other path that settles a missed task is recoverDelegatedTasks, and it runs only at server startup (serverRuntimeStartup.ts:554). Until a restart, the row stays running.

On the affected database, the data is fine: running the startup recovery against a copy settles the row correctly. That points at the dropped reaction rather than at the finalize logic. My server had not restarted since before the failure, so recovery never ran.

Separate, already fixed on main: in v0.1.9, task_cancel on a child whose run had already ended only disposed the completion delivery and never settled the parent's row. #21676 makes cancelDelegatedTask end with finalizeAppOwnedSubagent. It shipped in the v0.1.10 nightlies, not in v0.1.9.

Impact

Major degradation or frequent failure

Version or commit

v0.1.9 (desktop). Same code path on main @ 449deb6.

Environment

Linux, T3 Code desktop v0.1.9. Parent: Claude. Child: Codex (thread/start failed with ENOSPC because the filesystem ran out of inodes).

Logs or stack traces

# Codex app-server, child thread/start
error creating thread ... No space left on device (os error 28)

# task_status on the child task
status: failed, progress: result_available, resultContextTransferId: null

# task_cancel on the same task
{"status":"failed"}   # parent row still "running" afterwards

The server log for the exact moment had already rotated, so I could not capture the error the reaction hit. Storage errors were ongoing at that time, so a failed SQLite read is the likely candidate.

Workaround

Restart the T3 server. Startup recovery settles the stuck row and wakes the parent.

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