Background agent task-notifications silently dropped when multiple agents complete within seconds
Summary
When multiple background agents (run_in_background: true) complete within a narrow time window (< 30 seconds), some <task-notification> messages are silently dropped. The parent session never receives them. The agents themselves complete successfully (stop_reason: "end_turn"), produce all expected output files, and their output logs are written — but the orchestrating session is never notified.
This is distinct from #36690 (notifications arriving at wrong timing / racing with user questions). Here, notifications never arrive at all.
Reproduction
Setup
- Claude Code v2.1.87, macOS, claude-opus-4-6
- Orchestrator spawns N background agents simultaneously via Agent tool
- Each agent writes files to disk upon completion
Steps
- Spawn 4–6 agents with
run_in_background: truein a single message - Wait for all agents to complete (they finish within ~30 seconds of each other)
- Observe that some
<task-notification>messages never arrive
Observed behavior (2026-04-09 session)
Writer batch (4 agents, simultaneous spawn):
| Agent | Completed | Notification |
|-------|-----------|-------------|
| writer-batch-1 | 04:32:12 | ✅ Received |
| writer-batch-2 | 04:32:20 | ✅ Received |
| writer-batch-3 | 04:32:31 | ✅ Received |
| writer-batch-4 | 04:32:40 | ❌ Never received |
Fact-checker batch (6 agents, simultaneous spawn):
| Agent | Completed | Notification |
|-------|-----------|-------------|
| fc-batch-1 | 07:49:46 | ✅ Received |
| fc-batch-2 | 07:49:54 | ✅ Received (delayed) |
| fc-batch-3 | 07:50:01 | ✅ Received |
| fc-batch-4 | 07:50:09 | ❌ Never received |
| fc-batch-5 | 07:50:15 | ✅ Received |
| fc-batch-6 | 07:50:22 | ✅ Received |
Image-gen batch (3 agents, simultaneous spawn):
| Agent | Completed | Notification |
|-------|-----------|-------------|
| img-batch-1 | 08:16:55 | ✅ Received |
| img-batch-2 | 08:17:01 | ❌ Never received |
| img-batch-3 | 08:17:06 | ✅ Received |
Drop rate: 3/13 (23%)
Key evidence that agents completed successfully
- All output files exist on disk with correct content
- All agent output logs show
stop_reason: "end_turn"(not crash/timeout) - Completion timestamps in output logs confirm work finished
Impact
- Automated pipelines stall indefinitely — if no human is present to manually check file-based checkpoints, the orchestrator waits forever for a notification that will never come
- Workaround required — timeout-based file checkpoint polling after last received notification (adds ~60s latency)
- The system prompt states "you will be automatically notified when it completes — do NOT sleep, poll, or proactively check" — but this guarantee doesn't hold when agents complete near-simultaneously
Environment
- Claude Code version: 2.1.87
- Model: claude-opus-4-6 (orchestrator), claude-sonnet-4-6 + claude-opus-4-6 (agents)
- Platform: macOS Darwin 25.2.0
- Session type: Scheduled task (automated, no user present)
Related
- #36690 — Background task notifications race with pending user questions (different failure mode: notifications arrive but at wrong time; here they never arrive)
- #31683 — Sub-agents docs missing background agent completion notification content
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗