10 background Agent tasks stuck running for 34+ hours, no way to cancel, burned ~1M tokens
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Subagent behaved unexpectedly
What You Asked Claude to Do
I think i asked it to do research. I cant find the chat
What Claude Actually Did
I had 10 background Agent tasks running in Claude Code (desktop app) on the
same project. Came back to check and all 10 were still showing "Running" —
each one had been going for over 34 hours straight (34h30m to 34h40m each).
Combined they'd burned around 1.08 million tokens with nothing to show for
it — no completed output, no visible progress, just climbing token counts.
There was no working way to stop them from the task panel. None of the
controls on the individual task rows actually cancelled anything.
This burned through my weekly usage limit and used up the last day of my
Fable model access on tasks that never finished or produced anything usable.
Task list for reference (all typed "Agent", all showing "Running"):
- Verify Code Architecture track findings — 34h39m45s, 122.6k tokens, 76 tool uses
- Verify Database/Persistence track findings — 34h39m27s, 130.3k tokens, 46 tool uses
- Verify Security/Privacy track findings — 34h39m01s, 102.9k tokens, 33 tool uses
- Verify app lock and encryption fixes — 34h38m53s, 71.8k tokens, 19 tool uses
- Verify UI/UX/Onboarding track findings — 34h38m47s, 118.5k tokens, 74 tool uses
- Verify billing and release signing fixes — 34h38m38s, 98.3k tokens, 18 tool uses
- Verify Resume/Cover Letter Quality track findings — 34h38m36s, 126.5k tokens, 17 tool uses
- Verify remaining Resume Quality findings — 34h38m08s, 76.0k tokens, 14 tool uses
- Verify Store/Legal/Launch Prep track findings — 34h37m43s, 129.7k tokens, 38 tool uses
- Verify remaining minor sell-readiness items — 34h31m40s, 99.3k tokens, 27 tool uses
I'd like to understand why these got stuck with no way to recover or cancel
them, and given they produced no usable output, I'd like the tokens
credited back.
Expected Behavior
they ran 34+ hours for something that usually takes 10 or 20 mins... i didnt knotice it was runnning in the background. it seems the agents keeps running... i even still see the light yellow bubble there and nothing in tasks but its still runnnig
Files Affected
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
Yes, every time with the same prompt
Steps to Reproduce
not sure. ask your claude to do real research on a topic.
Claude Model
Other
Relevant Conversation
Impact
Critical - Data loss or corrupted project
Claude Code Version
v1.19367.0
Platform
Anthropic API
Additional Context
_No response_
Showing cached comments. Read the full discussion on GitHub ↗
9 Comments
This is the visibility and control gap in a nutshell: background agents run autonomously, which is the feature, but when they get stuck there is currently no recourse short of force-quitting the whole session.
A few things that have helped others in the same situation:
~/.claude/projects/<proj>/<session-id>/subagents/directory contains one JSONL file per background agent. If the agent is genuinely looping, the last few entries will be repetitive tool calls. That can at least tell you what each stuck agent was doing when it went sideways.pkill -f "claude.*--agent"will kill child Claude processes associated with background agents without nuking your main session on desktop. Not elegant, but it stops the bleeding.The root issue is that background agents have no max-turn or max-token cap independent of the main session, and the task panel's cancel button does not propagate a kill signal to the subprocess. These are known gaps -- #22625 (per-subagent token tracking) and the agent hierarchy dashboard request (#24537) both touch this. Worth leaving a link to this report there.
If you are doing parallel research workloads with agents, one pattern that reduces this risk: use Workflow builder agents with explicit
maxTurnsper stage rather than open-ended backgroundAgenttasks. The workflow runner does enforce stage timeouts. Cold comfort for the quota that's already gone, but worth the config overhead going forward.I saw your issue about background agents getting stuck for 34+ hours and burning ~1.08M tokens with no output. That looks like a classic agent loop / cost-spike failure pattern.
I’m the solo founder of Rootlyze, a public-beta tool that turns failed AI-agent runs into diagnosis, evidence signals, prevention guidance, and proofpacks.
If you have a sanitized trace/log from one of those sessions, I can run it through Rootlyze and send back a short proofpack showing the likely failure family, evidence signals, and what to check next. No secrets needed.
Want me to try it on one trace?
yes. I dont know what that stuff is.. very basic developer here lol
On Wed, Jul 8, 2026 at 6:46 AM Bosco @.***> wrote:
No worries — you don’t need to understand the category first.
Think of Rootlyze as a simple “scan my failed AI/dev run and tell me what went wrong” tool.
Easiest ways to try it:
You don’t need to prepare anything fancy.
Just remove secrets/API keys/private data and send one thing that failed — terminal output, agent trace, error log, or a file/folder with the failure.
I can run it and show you the proofpack result: what failed, evidence, likely cause, what to try next, and what Rootlyze cannot safely conclude.
This matches a failure pattern I have seen across a few extended overnight runs.
The core problem: background agents have no heartbeat-to-cancel signal path. From the task panel UI, "cancel" is effectively advisory -- if the agent is mid-tool-call (especially a long WebSearch or subagent dispatch) it will not see the cancellation until the current tool returns. If the tool itself is stuck, the agent never gets the signal.
A few things that helped in my setup:
sqlite3 ~/Library/Application\ Support/Claude/claude_code.db "SELECT * FROM workflow_tasks WHERE status='running' ORDER BY created_at DESC LIMIT 20;"
Stale ones will have a start_time well before your last process restart. Safe to update to 'failed' manually.
The 1M token burn with zero output is the painful part. Until there is a server-side rate-limit-per-session (not per-day), this is a real risk with any long-running background orchestration.
Worth noting: if the tasks showed climbing token counts but no output, the agents were probably in a compaction/spawn loop -- they compact, lose context, re-read the task spec, decide to spawn sub-agents again, repeat. Bug 1 and Bug 12 in issue #54393 describe this exact pattern if you want the full breakdown.
The core issue here is the same as #68619 and #73829: the agent has no concept of "I'm not making progress." It keeps running identical operations for 34 hours because:
A PreToolUse hook solves all three:
ThumbGate implements all three as PreToolUse hooks. Free to try:
npx thumbgate initThe principle: the agent should never be the one deciding when to stop. That decision belongs to a layer it can't override.
This is a painful bug - running 10 background agents for 34+ hours with no cancel path is a real problem, especially when it burns through weekly usage limits.
A few things that might help while Anthropic works on a fix:
From the terminal, you can try killing the daemon process directly:
pkill -f "claude daemon run"
Then restart Claude Code. The background agent state should reset.
If you want to prevent this from happening again, adding this to ~/.claude/settings.json disables the agent view entirely so background tasks cannot accumulate silently:
"disableAgentView": true
The root problem you're hitting - no visibility into which background sessions are actually running versus stuck, and no reliable cancel - is something a number of people are building tooling around. If you end up running multi-agent workflows regularly, it may be worth looking at tools that give you an external view of session state rather than relying on the built-in agent panel alone. Worktree-per-task isolation also helps limit blast radius when a session goes runaway.
Hope the token situation gets made right.
Same pattern I've seen when orchestrating multiple background sessions: the cancel/stop controls in the task panel update the UI state but don't propagate a real kill signal down to the Claude subprocess (or its process group). So the task shows as "stopping" or grey but the agent keeps running and consuming tokens underneath.
A few things that helped in similar setups:
ps aux | grep claude, check whether Claude subprocesses are still alive. The task panel being unresponsive doesn't mean the process is dead.killall node(or equivalent for your platform) after quitting the app is the nuclear option but actually stops the burn.The 34-hour runtime with 1M tokens and no output is consistent with a stuck tool call that keeps retrying rather than the agent making progress. The verification tasks you described can get stuck if the agent can't reach a file or tool it expects.
Worth filing a billing support ticket -- Anthropic has credited users in confirmed stuck-agent cases.
This is a painful one -- 1M tokens burned with no usable output and no cancel path is a significant trust problem for anyone running agents in batch.
The core issue seems to be that the task panel controls do not actually cancel the underlying worker -- they may update UI state without sending a stop signal to the running agent process. Some questions that could help pinpoint:
claude --bgfrom the CLI?For the token waste angle: there may be an agent supervision gap where the task panel loses the handle to the running worker but the worker keeps executing against your quota. We ran into a similar pattern and ended up needing a kill at the process group level rather than through the UI.
Sharing this in case the token-waste detail is useful for the refund request -- the pattern (controls failing to propagate stop to the worker, tasks continuing to run and charge) seems like it should qualify.