[Bug] Sub-agent orchestrators spawn redundant background polling loops instead of awaiting completion notifications

Status Open
Reported on v2.1.270
Maintainer reply None cached
Activity 0 comments · opened Sep 14, 2026

Bug Description
Title: Sub-agent orchestrators arm redundant background until watchers instead of waiting for child-agent completion notifications

Summary
When a general-purpose sub-agent spawns its own child agents with the Agent tool, it frequently
ends the turn by launching a background Bash until … sleep … loop that polls git status (or
a log) for the child's output files, and re-arms a new one on every turn that ends without a
notification. In one session a single orchestrator accumulated 15+ concurrent shell watchers.
The harness already re-invokes the parent when a child completes, so the watchers are pure
waste (one polling shell per loop) and clutter the task list.

Why it happens (from the built-in tool descriptions)

  • Bash: "Foreground sleep is blocked; use Monitor with an until-loop to wait on a condition."
  • Monitor: for a single notification, "use Bash with run_in_background and a command that

exits when the condition is true, e.g. until grep -q "Ready in" dev.log; do sleep 0.5; done."

  • Agent: "Subagents run in the background; you'll be notified when one completes."

The first two describe the only sanctioned way to wait. Neither says the idiom is for state
the harness cannot observe (a dev server, CI, a remote queue) and not for the agent's own
children. An orchestrator that has just delegated everything, has nothing else to do, and knows
sleep is blocked reaches for the until-loop and applies it to its children's files.

Repro

  1. In a fresh session, spawn a general-purpose agent (Opus or Sonnet) with a brief that says

"split this into N parts and delegate each to a sub-agent, then integrate their results".

  1. Watch the task list: after each Agent launch the sub-agent adds a `until [ -n "$(git status

--porcelain <expected file>)" ]; do sleep 1; done` background shell, often several per wave.

Suggested fix
Add one sentence to the Agent tool description and/or the Bash "sleep is blocked" sentence:
"Do not poll for a sub-agent's output; you are re-invoked automatically when it completes.
The until-loop / Monitor idiom is for external state the harness cannot track." Optionally,
have the harness refuse (or warn on) a background Bash whose command polls paths a live child
agent is expected to write.

Workaround
State it in the sub-agent brief: "After launching sub-agents, end your turn and wait for the
completion notification; never arm a shell loop to watch for their files."

Environment: Claude Code CLI on Windows 11 (PowerShell + Git Bash), model claude-fable-5-1
as orchestrator, sub-agents on opus/sonnet.

Environment Info

  • Platform: win32
  • Terminal: windows-terminal
  • Version: 2.1.270
  • Feedback ID: c4b85b03-0a1f-44c0-b653-882171919bc1

Errors

[{"error":"TelemetrySafeError: VirtualMessageList: itemKeys/messages length desync (keys=81 messages=80 range=[64,81))\n    at o8t (B:/~BUN/root/chunk-dj61bmmj.js:36:28828)\n    at twe (B:/~BUN/root/chunk-dj61bmmj.js:36:21633)\n    at Uo (B:/~BUN/root/chunk-hyn8a58h.js:18:20036)\n    at Qu (B:/~BUN/root/chunk-hyn8a58h.js:18:38202)\n    at em (B:/~BUN/root/chunk-hyn8a58h.js:18:84283)\n    at eg (B:/~BUN/root/chunk-hyn8a58h.js:18:83283)\n    at yc (B:/~BUN/root/chunk-hyn8a58h.js:18:83112)\n    at Wh (B:/~BUN/root/chunk-hyn8a58h.js:18:79637)\n    at Fe (B:/~BUN/root/chunk-hyn8a58h.js:18:6261)\n    at ot (B:/~BUN/root/chunk-hyn8a58h.js:18:4792)","timestamp":"2026-09-13T05:02:07.432Z"}]

View original on GitHub ↗