[BUG] Orphaned background Bash tasks spawned by a subagent keep running after 3 manual stops + refresh

Open 💬 0 comments Opened Jul 5, 2026 by jasminetsai-kleis

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?

A subagent I launched in the background (via the Agent tool with run_in_background: true) internally fanned out several parallel web-fetch operations — multiple Bash-tool calls crawling different external websites as part of a competitive research task. After the parent subagent completed and returned its final compiled result (a task-notification reported it as "completed"), several of its own internally-spawned child tasks kept running independently in the "Background tasks" panel — well past the parent's reported completion.

These orphaned tasks have now been running for 3+ hours each, consuming 70,000–85,000+ tokens per task and still climbing. Clicking the stop control (the checkbox) next to each task in the "Background tasks" panel, and refreshing the app, does not stop them — after refresh they still show status "Running" with elapsed time continuing to increase. This has been attempted 3 separate times on the same tasks with no effect.

What Should Happen?

  1. When a background subagent completes and returns its final result, any child processes it spawned internally (e.g. Bash-tool web fetches it launched itself) should be automatically terminated/joined — they should not be able to outlive the parent task as untracked orphans.
  1. Clicking the stop control on a background task in the "Background tasks" panel should reliably and immediately terminate the underlying process. Once stopped, it should not reappear as "Running" after a refresh.

Error Messages/Logs

No explicit error was surfaced to the user. The only symptom is the "Background tasks" panel continuing to show these tasks under "Running" with increasing elapsed time and token counts, e.g.:

- "Fetching https://www.akr-performance.com/brands/depo" — 3h11m53s, 82.5k tokens, 35 tool uses, Bash
- "Fetch peripower Amazon product page for seller info" — 3h11m46s, 71.4k tokens, 32 tool uses, Bash
- "Extract PDP JSON-LD and TYC certifications page text" — 3h11m26s, 83.2k tokens, 37 tool uses, Bash

After 3 stop attempts + refresh, 2 of the original tasks disappeared but 2 different-looking tasks remained/reappeared instead:

- "Fetching https://blog.fugle.tw/post/earnings-call-1522-202..." — 3h19m05s, 83.2k tokens, 37 tool uses, Bash
- "Fetching http://ctrl.chcg.gov.tw/book/no07/p7.htm" — 3h18m40s, 82.5k tokens, 35 tool uses, Bash

Steps to Reproduce

I don't have a minimal standalone repro — this emerged from a complex multi-agent research workflow rather than a simple script. The pattern that triggered it:

  1. In an active chat session, use the Agent tool to launch a subagent in the background (run_in_background: true) whose task requires researching/crawling 5+ different external websites.
  2. The subagent internally fans out multiple parallel Bash-tool calls (fetch/crawl requests to each target site) to do this concurrently rather than one at a time.
  3. The subagent completes its overall task and returns a final compiled result; the top-level task-notification reports it as "completed".
  4. Open the "Background tasks" panel.
  5. Observe that some of the subagent's individually-spawned Bash fetch tasks are still listed under "Running", despite the parent subagent already reporting completion.
  6. Click the stop checkbox next to each still-running task.
  7. Refresh the app/panel.
  8. Observe the tasks are still listed as "Running", with elapsed time still increasing.
  9. Repeat steps 6–8 up to 3 times — the tasks persist.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.161

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

This occurred during a long-running Claude Code chat session (3+ hours) doing a multi-phase research/planning workflow for a client project. The workflow involved several rounds of launching parallel background subagents via the Agent tool for competitive research (crawling multiple external websites per subagent).

Multiple models were used during the session (session involved switching between models mid-conversation).

I was not able to obtain the underlying task IDs for these orphaned tasks from within the chat/agent tool surface — my own task-tracking tools only expose a separate todo-style task list and don't enumerate or let me terminate these background Bash tasks, so I could not stop them programmatically from within the conversation either.

Screenshots of the "Background tasks" panel showing the stuck tasks (before and after 3 stop attempts) are available and can be attached to this issue.

View original on GitHub ↗