[Bug] Background agent resume creates retry loop — model doesn't wait for completion notification
Resolved 💬 6 comments Opened Mar 8, 2026 by KCW89 Closed Apr 11, 2026
Summary
When a background agent (run_in_background: true) is still running, the model repeatedly attempts to resume it instead of waiting for the automatic completion notification. This creates a wasteful retry loop of 3+ failed resume attempts, each returning the same error.
Reproduction Steps
- Launch an Agent with
run_in_background: true(e.g., an Explore subagent) - Before the agent completes, the model decides it needs the agent's results
- Model calls
Agent(resume: "agent_id") - Error:
Cannot resume agent {id}: it is still running. Use TaskStop to stop it first, or wait for it to complete. - Model does NOT wait — it continues working, then retries resume again
- Same error repeats 2-3 more times throughout the conversation turn
Observed Behavior
⏺ Agent(Resume KS task exploration) resuming a403a551f3894150b
⎿ Error: Cannot resume agent a403a551f3894150b: it is still running. Use
TaskStop to stop it first, or wait for it to complete.
⏺ [Model does other work...]
⏺ Agent(Resume KS task exploration) resuming a403a551f3894150b
⎿ Error: Cannot resume agent a403a551f3894150b: it is still running. Use
TaskStop to stop it first, or wait for it to complete.
⏺ [Model does other work...]
⏺ Agent(Resume KS task exploration) resuming a403a551f3894150b
⎿ Error: Cannot resume agent a403a551f3894150b: it is still running. Use
TaskStop to stop it first, or wait for it to complete.
Expected Behavior
One of:
- Model should wait for the background completion notification instead of polling with resume calls (the system prompt says "you will be automatically notified when it completes — do NOT sleep, poll, or proactively check")
Agent(resume)on a running background agent should block until the agent completes, then return the result (instead of erroring)- Rate-limit resume attempts — after the first "still running" error, suppress further resume calls for that agent ID until the completion notification arrives
Root Cause Analysis
The model's system prompt instructs it to not poll, but the model lacks a mechanism to actually "wait" for a background agent. When it needs the results, its only option is to call resume, which fails. There's a gap between the instruction ("wait for notification") and the available tools (no "wait" or "block until complete" primitive).
Impact
- Token waste: Each failed resume attempt costs ~200 tokens (tool call + error response)
- Context window pollution: 3+ identical error messages clutter the conversation
- UX confusion: User sees repeated errors with no resolution
Environment
- Claude Code v2.1.71
- Platform: macOS (darwin)
- Model: Claude Opus 4.6
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗