[BUG] Status line context window misreports when sub-agent usage is counted
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?
In a main conversation, when Claude Code invokes sub‑agents (such as the explorer) to perform tasks, the context window usage percentage shown in the status line appears to include the tokens consumed by the sub‑agent. This leads to the status line reporting a much higher context usage than expected. For example, after heavy work by sub‑agents the conversation should still have about 80% of the context window free, but the status line incorrectly shows only 20% free.
Auto‑compact seems to trigger at the correct threshold regardless of the incorrect status line number, so Claude Code must internally know the correct context usage. The status line should therefore reflect the true available context and not include sub‑agent usage.
What Should Happen?
The status line should accurately reflect the context window usage for the main conversation only. Sub‑agent execution (e.g., explorer) should not count toward the conversation's context usage. After sub‑agent tasks, the status line should show the correct remaining percentage (for example, around 80% free if most tokens were used by a sub‑agent). The number reported by the status line should align with the threshold used by auto‑compact and indicate the true available context.
Error Messages/Logs
Steps to Reproduce
- Start a main conversation with Claude Code and note the status line’s context window usage.
- Invoke a sub-agent (for example, the Explorer agent) to perform tasks within the same conversation.
- After the sub-agent completes its work, check the status line: the context window free percentage should remain high (around 80%) since the main conversation hasn’t used many tokens.
- Observe that the status line instead shows a very low free percentage (around 20%), indicating that the sub-agent’s context usage has been incorrectly counted.
- Note that auto-compact triggers at the correct threshold despite the incorrect status line, confirming that Claude Code internally knows the correct context usage but the status line display is wrong.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.65
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗