Skip to content

[Bug]: Delegated task finalizes when a wake turn ends while another t3_background_wait task is still running #26605

Closed

Description

@derek-eliza

Before submitting

Area

apps/server

Steps to reproduce

  1. A parent thread starts a Claude child with delegate_task (mode: "async", isolation: "worktree").
  2. In its first turn, the child starts two Bash commands with run_in_background: a short one (a test run, about 30 seconds) and a long one (sleep 330). It calls t3_background_wait with both task IDs, then ends its turn.
  3. The short command exits. Claude Code starts a wake turn (run 2) in the child for that exit.
  4. Run 2 handles the short command's result, says it is still waiting on the long command, and ends its turn. It does not call t3_background_wait again.
  5. The long command exits about five minutes later and starts run 3.

Expected behavior

The task stays open (waiting_for_children) while any task registered with t3_background_wait is still running, including after a wake turn for a different task ends. The parent receives the child's result after run 3.

Actual behavior

When run 2 ends, the task finalizes as completed, and the parent is woken with run 2's interim text as the result ("Still about five minutes until reset. The timer task will notify me."). The long command registered in run 1 is still running at that point. Run 3 starts about five minutes later, after the parent has already been told the task finished.

Observed timeline (relative to the child's first t3_background_wait):

T+0s     child run 1: t3_background_wait([shortTask, longTask]); run 1 ends at T+9s
T+17s    shortTask exits; child run 2 (wake turn) starts
T+38s    run 2 ends; task finalized as completed with run 2's text; parent notified
T+330s   longTask exits; child run 3 starts and keeps working

Impact

Major degradation or frequent failure

Logs or stack traces

# notification delivered to the parent at T+38s
Delegated task <taskId> (<title>) [completed]:
Still about five minutes until reset. The timer task will notify me.
# t3_thread_read on the child at T+330s+
thread.status: running, activeRunId: ...:ordinal:3, recentRuns: [3 running, 2 completed, 1 completed]

Workaround

The child can call t3_background_wait again with the remaining task IDs before ending each wake turn. The parent can check t3_thread_read for the child's activeRunId instead of trusting the completed notification.

Activity

  1. juliusmarminge commented on Oct 28, 2026

    @juliusmarminge
    Member

    Duplicate of https://git.cafe/pingdotgg/t3code/issues/24297.

    I ran your steps on main at 886d8f6: a Claude parent, delegate_task async with worktree isolation, and a Claude child that starts two background Bash commands, calls t3_background_wait with both IDs, and ends its turn. On the wake turn the child does not register again. I ran it twice: once with 15 s and 120 s commands, and once with 30 s and sleep 330 where the wake turn reads the short command's output first.

    In both runs the task stayed open when the wake turn ended, and the long command stayed in the roster as awaited. The task finalized when the long command exited, in the gap before that exit's wake turn was registered. Times from the second run:

    19:24:27.091  child run 2 (wake turn for the short command) ends; task still running
    19:29:18.262  task finalized as completed with run 2's text ("... still waiting on the 330-second command.")
    19:29:18.351  parent woken with that text
    19:29:18.530  child run 3 (wake turn for the long command) starts
    

    That is the race in https://git.cafe/pingdotgg/t3code/issues/24297, and it produces the interim result you quoted. On this commit the parent also gets run 3's result later, as a second task. If you see a task finalize at the end of a wake turn while an awaited command is still running, comment there with your T3 Code version and the run and task timestamps from statev2.sqlite.

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