Background agents should stop immediately on permission auto-deny instead of retrying and wasting tokens
Resolved 💬 3 comments Opened Feb 18, 2026 by KIMSEUNGGYU Closed Feb 21, 2026
Problem
When a background agent (run_in_background=true) attempts to use a tool that requires user permission (e.g., Write, Edit, Bash), the permission prompt cannot be shown because the agent runs in the background. The tool is auto-denied.
However, the agent does not stop. Instead, it keeps retrying with alternative tools:
Writedenied → triesEdit→ triesBash cat >→ triesWriteagain → ...
This cycle continues until the agent exhausts its turn limit, consuming massive amounts of tokens with zero useful output.
Impact
In my case:
- 7 background agents were launched to write files in parallel
- Each agent consumed ~100K tokens retrying after permission denial
- Total waste: ~677,000 tokens
- This consumed 93% of my 5-hour rate limit, making Claude Code unusable for hours
Expected Behavior
When a background agent receives an auto-deny on a tool:
- The agent should immediately stop (or at minimum, stop after 1-2 denials)
- Return a clear message: "Permission denied for [tool]. Background agents cannot request user permissions."
- Not retry with the same or equivalent tools
Current Behavior
The agent keeps retrying different write methods (Write → Edit → Bash) in a loop, burning through tokens with no possibility of success.
Reproduction Steps
- Launch a
Taskwithrun_in_background=true - The task prompt requires writing files (using
WriteorEdittool) - Do NOT have auto-allow configured for those tools
- Observe: the agent retries repeatedly, consuming tokens until max turns
Environment
- Claude Code CLI
- Model: claude-opus-4-6
- OS: macOS (Darwin 25.1.0)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗