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:

  • Write denied → tries Edit → tries Bash cat > → tries Write again → ...

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:

  1. The agent should immediately stop (or at minimum, stop after 1-2 denials)
  2. Return a clear message: "Permission denied for [tool]. Background agents cannot request user permissions."
  3. 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

  1. Launch a Task with run_in_background=true
  2. The task prompt requires writing files (using Write or Edit tool)
  3. Do NOT have auto-allow configured for those tools
  4. 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)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗