Claude Code background agents can't be stopped or write files
Claude Code background agents that can't be stopped, have write permissions denied, or stall: the foreground fix, and what Sledbot can and can't do.
GuideUpdated 6 min read
On this page
You told Claude Code to stop, and tokens kept going. Or a background agent came back with "I need Write and Edit permissions" and changed nothing. Or a subagent just sits there and never reports back.
These are three symptoms reported on the Claude Code GitHub repository, in issues #45250, #40751 and #76220. We have not re-checked those issues, so look at them for current status before assuming anything has changed. Everything below separates what users report from what we have verified.
Why it happens
The reports describe three separate problems. We can relay what users describe, not Claude Code's internal cause.
- Stop doesn't reach the background agent. Agents launched with
run_in_backgroundreportedly keep consuming tokens after the user tells Claude to stop. No cause is documented in the reports, and no fix was reported. - Permission prompts are auto-denied. A background agent has no one at the keyboard to answer a prompt, so the reports say the prompt is denied automatically. An agent that must write or edit then finishes with a message like "I need Write and Edit permissions".
- Stalls. One report says every session shows up as a background agent and that subagents stall every time. It is a single report, and we know of no confirmed cause or fix.
| Symptom | Reported cause | What to do |
|---|---|---|
| Keeps working after "stop" | Not documented | End the whole session, then verify usage |
| "I need Write and Edit permissions" | Prompt auto-denied in the background | Run that agent in the foreground |
| Subagents stall | Not confirmed | Run the work in the foreground |
Fix "I need Write and Edit permissions"
The reported fix is to run write-dependent agents in the foreground, where you can see and answer the prompt.
- Ask Claude to run that agent in the foreground, and not with
run_in_background. - Stay with the session so you can answer permission prompts as they appear.
- Confirm that the agent really ran in the foreground. If it still reports that it can't write, treat the run as failed and re-run it rather than trusting the summary.
- Check the files. An agent that says it finished may have written nothing, so look at the diff in your repository before moving on.
We know of no documented setting that turns background agents off, so we won't point you to one. We also haven't verified that any particular wording in a prompt changes how Claude launches an agent.
Splitting the work
If one task mixes reading and writing, you can still use background agents for the read-only part. Research, searching the codebase and summarizing files don't need write permission, so the reported denial doesn't apply to them. Run the part that edits files in the foreground afterward, with the findings in hand. This is our suggestion, not something the reports confirm, so watch the first run.
Stop a background agent that won't stop
No one has reported a way to cancel one background agent from inside the session, so stop at the session level.
Quit the Claude Code session in its terminal, or close the terminal running it.
If the terminal won't respond, quit the terminal app. In Activity Monitor, search for
claudeand quit any process that is still listed.To check from Terminal instead, run the command below. It lists running processes whose command line contains
claude, and changes nothing.text pgrep -fl claudeOpen your Claude usage page, or any local usage tool you trust, and watch the numbers for a few minutes. If they still climb, something is still running somewhere.
We haven't verified that ending the session always ends a background subagent, which is why step 4 matters. If you run Claude Code on a remote machine, quitting the terminal on your Mac may not end it there. Check that machine too.
Subagents that stall
Running the work in the foreground avoids the background path entirely, so it is the closest thing to the reported fix. If a foreground run also hangs:
- Interrupt it and read the last output to see where it stopped.
- Restart the session and resume the conversation instead of waiting indefinitely.
- Re-issue the task in smaller pieces. We can't promise this helps, but a smaller task is easier to check and cheaper to repeat.
We have no confirmed fix beyond that.
Where Sledbot helps, and where it doesn't
Sledbot is only partly relevant. It controls the whole agent terminal, not the subagents inside a Claude Code session, so it cannot cancel a single background task.
If you run Claude Code in a Sledbot tab, this is what it covers:
- Stop the whole agent. On the agent session page, click Stop and confirm Stop
<name>?. The terminal stays so you can read what happened. The pane's More menu also has Stop. Closing a running tab with ⌘W asks Stop<name>? and offers Stop and close; the worktree and files stay. - Restart. Click Restart to continue. It restarts the agent with its conversation where possible.
- Check spending. Insights (⇧⌘I) shows Tokens and Cost, read from Claude Code's local logs. It reports usage and does not cap it.
- Find leftovers. Resources (⌥⌘R) lists per-terminal processes and Left running. Each process has Quit (SIGTERM) and Force Quit (SIGKILL).
- Answer foreground prompts. A Claude Code permission prompt marks the agent as needing you. You see it in the Needs you count, on the Dock badge, and as a banner if you are in another app. On the agent session page you answer with Yes or No. It cannot recover a prompt that Claude Code already auto-denied in the background.
- Spot a quiet session. When an agent is working, has produced no output for 10 minutes and uses no CPU, Sledbot shows a banner on the agent header (and on Today) saying it looks stuck. It offers Send a nudge, Restart with resume, Switch account and See what happened. The banner appears only in that case. If one subagent hangs while the session keeps printing output, Sledbot won't notice.
If you only run one Claude Code session at a time, the terminal steps above are enough. More about the app is on the Sledbot page.
Checklist before you try again
- Write-dependent agents are launched in the foreground.
- You are watching the session so you can answer prompts.
- After stopping, usage stopped climbing, checked over a few minutes.
- No leftover
claudeprocesses remain on your Mac or on any remote machine you used. - The files the agent said it changed actually changed.
If nothing works
Report it to Anthropic through the Claude Code GitHub repository. If your case matches the three issues named above, add your details to them instead of opening a duplicate. Include:
- Your Claude Code version and macOS version.
- What you asked Claude to do, and whether the agent was started in the background.
- The exact message you saw.
- Timestamps, and whether usage kept climbing after you ended the session.
- What you already tried, such as ending the session or quitting the terminal.
Claude Code version: (your version), macOS (your version)
I started a subagent with run_in_background. After I told Claude to stop, token usage kept increasing for about (N) minutes.
Separately, a background agent that needed to edit files ended with "I need Write and Edit permissions".
Time of the problem: (date and time, with time zone)
Steps tried: ended the session, quit the terminal, checked for leftover claude processes.
Expected: the background agent stops when asked, or write permission prompts reach me.If the usage looks wrong on your bill or plan, also contact Anthropic's support with the same details, since the repository is for bug reports and not account questions.
Common questions
Is there a setting to disable background agents?
We know of none, and we won't guess at one. The practical lever is asking for foreground runs and checking that is what happened.
Will quitting the session definitely stop the tokens?
We haven't verified that it always does. Check your usage afterward rather than assuming.
Can Sledbot cancel just one subagent?
No. It stops or restarts the whole agent terminal, not tasks inside a Claude Code session.
Why did the agent report success when nothing was written?
The reports say the agent finishes with a message about missing permissions instead of failing loudly. Read the message and check the diff, and don't rely on the agent's summary alone.