[BUG] Background sub-agents stay "In esecuzione" in the Activity panel after they've completed
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?
Title: Background sub-agents stay "In esecuzione" in the Activity panel after they've completed
Environment: Claude Code (desktop/web app), model Opus 4.8, Ultracode on
Description:
Sub-agents launched via the Agent tool complete and return their final result to the main loop, but the "Attività in background" panel keeps showing them under "In esecuzione" with a live-incrementing timer (observed 15–23+ min after completion). This makes it look like agents are still running and consuming tokens when they have finished.
Evidence of the mismatch:
The agents returned their complete final output (review verdicts) to the main conversation.
From the main loop, TaskStop <id> and TaskOutput <id> both return "No task found" for those agent IDs, and TaskList is empty → the harness no longer tracks them as active/stoppable.
Yet the UI panel still lists them as "In esecuzione".
Impact: The assistant cannot terminate them (harness reports them as non-existent), and the user has no reliable way to tell whether they're actually running or just stale UI state. Erodes trust ("agents look stuck/running forever").
What Should Happen?
Once an agent's turn ends, it should move to "Terminato" (or a distinct "idle/resumable" state), not remain in "In esecuzione" with a running timer. Ideally the token/tool counters should visibly stop.
Error Messages/Logs
Steps to Reproduce
In a Claude Code session (desktop/web app), give a task that leads the assistant to launch several sub-agents via the Agent tool — e.g. a review pipeline (supervisor → reviewer → critic → a second critic re-review).
Let the assistant run them as background agents and wait for each to finish (it awaits their results, e.g. via TaskOutput).
Each agent returns its final result to the main conversation (the assistant reports their verdicts) — i.e. their turn is complete.
Open the "Attività in background" panel.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
1.17377.1
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
5 Comments
Corroborating this on the same environment: Claude Desktop 1.18286.0 (build
259c3f), macOS, embedded Claude Code engine 2.1.197.Counted ~15 sub-agents stuck showing as "running" in the Activity panel over a 2-hour window today, none of which were actually active in the harness (same
TaskStop/TaskListmismatch described above). While reporting this exact issue, two more phantom "running" entries appeared for agents that had already returned final output — and they were convincing enough that I (the human) assumed the assistant was still mid-task and didn't notice it was waiting on a reply. So beyond the token/trust erosion already noted, this actively stalls conversations: the UI signal that's supposed to tell the user "still working" vs "done, waiting on you" is exactly what's broken.+1 for prioritizing — this is a session-blocking UX bug, not just a cosmetic one.
Small follow-up data point: stopping the two phantom "running" entries from the Activity panel's own Stop button worked fine (as it always has) — it's specifically the harness-side
TaskStop/TaskListcalls from the main loop that report them as already gone.So this isn't just stale UI rendering with nothing behind it — the desktop-level supervisor still has something live to kill for these entries, while the harness's own task registry has already dropped them. Points at the two tracking systems (desktop/UI supervisor state vs. harness
TaskListregistry) drifting out of sync with each other, rather than one side simply failing to update.Cross-linking a likely-related report: #73267 (Windows, filed ~5 hours before this one). Same root mismatch — harness-side task tracking (
TaskList) correctly shows no active tasks once the agent(s) finish, but the desktop UI's own state never clears — just surfacing on a different UI element there (the whole session's "working" spinner, rather than a per-sub-agent row in the Activity panel here).Flagging as related rather than a literal duplicate: different OS (Windows vs macOS) and different UI surface, so worth tracking whether the fix needs to land in one shared desktop-UI/harness sync path or two platform-specific ones. Please don't auto-close either as a dup of the other — they're two manifestations of what looks like the same underlying desync, not the same bug report.
Pre-emptively distinguishing this from two other open issues that share "subagent"/"background agent" vocabulary but describe different bugs, in case a dedup pass clusters them:
TaskStop/TaskList) already correctly shows it as gone. Confirmed via a live repro: stopping the phantom entry from the UI's own Stop button worked fine, meaning the desktop-side supervisor still has something live to act on — the harness-side registry and the UI/supervisor state are just out of sync with each other. Different subsystem, different symptom.Agenttool being entirely absent from a sub-agent's tool surface. Not related — this issue has nothing to do with nested spawning; it's a single-level agent (no nesting involved) whose UI representation doesn't clear on completion.Leaving this note so the two get triaged independently rather than merged.
Confirming this on macOS, same setup as the report.
Same mismatch you describe, checked from the main loop:
So nothing is actually running. It reads as stale UI state that never clears once the background sub-agents complete, not real activity. Same symptom as the Windows report in #73267.