[BUG] Background sub-agent reported "completed" while its own background Bash task is still running
Summary
A sub-agent launched with run_in_background: true starts a Bash command with run_in_background: true and ends its turn. The parent gets a <task-notification> with <status>completed</status> and the sub-agent's interim text ("Waiting on the spec run."). When the shell finishes, the sub-agent is woken again and later sends another completed with the real result.
The 2.1.288 notification text says it "fires each time this agent stops with no live background children of its own". In this case it fired while the sub-agent's background child was still running.
Related: #93889 (sub-agent background tasks outlive the sub-agent). This report is about the status the parent and hosts see, not the cleanup.
Version: Claude Code 2.1.287 and 2.1.288, Linux (Ubuntu 24.04), running under T3 Code.
Steps to reproduce
- Launch a background sub-agent whose brief says: run
sleep 300withrun_in_background: true, then end your turn saying you are waiting. - The parent immediately receives
<status>completed</status>for that agent, with the "waiting" text as its result. - About 5 minutes later the agent is woken by its shell's notification and sends a second
completed.
Observed in a real session: three completed notifications for the same agent within 3 minutes, each carrying an interim "still waiting" summary. On 2.1.288 the agent ended its turn at 14:13:16 with its test run live, and the parent got completed at 14:13:16. The run finished at 14:49:09, and the real final report came at 14:49:45.
Why it matters
Hosts that read task status treat the first completed as the end of the work. T3 Code's idle reaper then stops the session after 30 minutes, which kills the still-running shells (filed with T3 Code: pingdotgg/t3code#15235). Coordinating agents also act on the interim text as if it were a final report.
Expected
While a sub-agent has live background tasks, report it as running or waiting, not completed. A separate status such as idle_with_background_tasks would work too.