[Bug]: A delegated task stays running and its parent is never woken when the parent's update for a failed child is dropped
Fix: #37225
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] 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):
- A parent thread calls
delegate_task(completionWake: "always"). - The child's provider session cannot start:
ensureThreadfails, so the child run settlesfailedwith "Provider turn failed to start". - The parent's reaction to that terminal
run.updatedfails once on a projection read (the test injects oneProjectionStoreReadErrorinto the readfinalizeAppOwnedSubagentmakes). - 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_statusreportsfailed/result_available, because it derives the status from the child run whentask.resultis null, butresultContextTransferIdis null.task_cancelreturns{"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
handleRunUpdateinapps/server/src/orchestration-v2/Orchestrator.ts. It callsfinalizeAppOwnedSubagentonce perrun.updatedevent (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 staysrunning.
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 @ 449deb635e.
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.