[BUG] Background agents get stuck on permission denied instead of exiting cleanly

Resolved 💬 3 comments Opened Jan 22, 2026 by ntroutman Closed Jan 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When background agents (run_in_background: true) encounter permission errors (e.g., Write permission for a directory outside the current project), they receive "auto-denied (prompts unavailable)" but don't exit cleanly. Instead, they remain in a waiting state, requiring the user to manually press Escape to dismiss each one.

Example prompt that triggers this:

Launch 3 background agents to update .gitignore in ~/ws/project-a, ~/ws/project-b, ~/ws/project-c

Each agent will:

  • Read the existing .gitignore (works)
  • Attempt to Write/Edit the file (permission denied)
  • Get stuck instead of exiting with a report

What Should Happen?

When a background agent hits a permission error it cannot resolve, it should:

Option A (Preferred): Surface the permission prompt to the user despite being a "background" agent, allowing the user to grant permission and let the agent continue. This is far better than having to restart the entire agent workflow.

Option B: Exit cleanly and report back to the parent agent:

Agent completed with errors:
- Write permission denied for /Users/x/ws/project-a/.gitignore
- Completed: [list what was done]
- Could not complete: [list what failed]

Option C: At minimum, recognize permission denied as a terminal state and exit cleanly with a status report, rather than waiting indefinitely.

Error Messages/Logs

Steps to Reproduce

  1. Start Claude Code in project directory A (e.g., ~/my-project)
  2. Launch multiple background agents that need to write files in different project directories (e.g., ~/other-project-1, ~/other-project-2)
  3. The agents will attempt to use the Write tool
  4. Write permission is auto-denied with message: "Permission to use Write has been auto-denied (prompts unavailable)."
  5. Observe: Each agent stays in a "waiting" state instead of exiting
  6. User must: Press Escape for each agent to dismiss them

Example prompt that triggers this:

Launch 3 background agents to update .gitignore in ~/ws/project-a, ~/ws/project-b, ~/ws/project-c

Each agent will:

  • Read the existing .gitignore (works)
  • Attempt to Write/Edit the file (permission denied)
  • Get stuck instead of exiting with a report

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.15 (Claude Code)

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

Warp

Additional Information

This was discovered when trying to use parallel background agents to update configuration files across multiple project directories. The workaround was to do the writes directly from the main agent (which has permission prompts available), but this defeats the purpose of parallel background agents.

The core issue seems to be that background agents have no clean "exit on unrecoverable error" path when they hit permission boundaries they cannot resolve.

View original on GitHub ↗

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