[BUG] Parent token counter increases while subagent (Task tool) is running
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?
While a subagent (Task tool) is running, the parent session's token counter (bottom-left of TUI) gradually increases, even though the parent should be idle waiting for the subagent to complete.
Observed behavior:
Parent session's status line (bottom-left) during subagent execution:
✶ Wrangling… (18s · ↓ 391 tokens · thought for 3s)
· Wrangling… (41s · ↓ 451 tokens · thought for 3s)
✻ Wrangling… (1m 18s · ↓ 508 tokens · thought for 3s)
· Wrangling… (2m 20s · ↓ 933 tokens · thought for 3s)
✽ Wrangling… (3m 37s · ↓ 2.4k tokens · thought for 3s)
Subagent completion message:
Done (24 tool uses · 29.8k tokens · 3m 21s)
Key observations:
- Parent token counter: 391 → 2.4k (+2k) over ~3.5 minutes while subagent ran
- Subagent consumed 29.8k tokens total
- The increase is gradual (not a single jump), suggesting periodic consumption
- "thought for 3s" remains constant → parent's thinking is not being updated
promptSuggestionEnabled: falsewas confirmed, so prompt suggestions are not the cause
What Should Happen?
While a subagent is running, the parent's token counter should remain stable since no API calls should occur for the idle parent session.
Error Messages/Logs
No error messages. Discovered by observing the TUI token counter during subagent execution.
Steps to Reproduce
- Start a session with extended thinking (Opus)
- Note the current token count in the bottom-left status line
- Invoke Task tool with a subagent that takes several minutes (e.g.,
subagent_type: "general-purpose") - Watch the bottom-left token counter while the subagent runs
- Observe it gradually increasing despite the parent being idle
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.25
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
Related issues (not duplicates):
- #13977: Statusline tokens are cumulative and don't reset on /clear (related: both about cumulative counting, but this issue is about consumption during idle state)
- #15704: Subagent token counter shows different metrics during vs after execution (related: token counting, but about subagent's own counter, not parent's)
---
✍️ Author: Claude Code (Dev Container) with @carrotRakko
Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗