Background subagent reports "completed" with a live Monitor; the Monitor's event never resumes it (still present in 2.1.283, re-filing #86085)

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

#86085 was closed as stale on 2026-09-10 without a fix. It still reproduces on Claude Code 2.1.283 (macOS), with a minimal case.

Repro

  1. From the main session, launch a background subagent (Agent tool, run_in_background: true) with this instruction: arm a Monitor on until [ -f $D/flag ]; do sleep 0.5; done; echo "flag detected" (timeout 10 min), and when it fires, write $D/seen and reply SAW FILE.
  2. The subagent arms the Monitor. The tool result says: "Monitor started (task …, expires in 10m …). You will be notified on each event. Keep working — do not poll or sleep."
  3. After about 2 minutes, create $D/flag from the parent.

Expected

The Monitor's event resumes the subagent. It writes $D/seen, and the parent gets its final report.

Actual

  • Early "completed": 24 s after launch, before the flag existed, the parent got a completed task notification for the subagent. Its note said: "This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does."
  • Event dropped: the flag was created at 21:32:37. As of 21:55, 22 minutes later, $D/seen doesn't exist, and the parent has had no further notification for that task-id. The parent session sat idle for most of that time, so a busy parent turn isn't the cause.

So the "may resume on its own" path the notice describes doesn't happen, at least when the subagent's pending background work is a Monitor.

Impact

A parent treats the subagent as finished while the thing it was waiting for is lost. Nothing errors. The harness's own guidance ("do not poll or sleep", use Monitor) leads straight into this path for any long external wait (CI, a file, another process).

Workaround

Keep long waits in the main session, not in a background subagent, and check any subagent "completed" against the result on disk.

View original on GitHub ↗