[BUG] Unexpected session model tokens usage for opus
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?
Seems that when you use a session with opus-A and running the commands using opus-B they have some complicated relations. Context copying or something. But you are paying for it.
My case was:
When running session on opus47, command on sonnet and subagents on haiku:
Total cost: $0.96
Total duration (API): 6m 48s
Total duration (wall): 4m 4s
Total code changes: 118 lines added, 0 lines removed
Usage by model:
claude-sonnet-4-6: 366 input, 14.0k output, 638.6k cache read, 48.4k cache write ($0.58)
claude-haiku-4-5: 265 input, 18.1k output, 741.4k cache read, 165.2k cache write ($0.3712)
And this is what I expect to see ^
When running session on opus47, command on opus46, and subagents on haiku:
Total cost: $2.08
Total duration (API): 7m 51s
Total duration (wall): 3m 34s
Total code changes: 120 lines added, 0 lines removed
Usage by model:
claude-opus-4-6: 1.5k input, 6.7k output, 295.6k cache read, 35.5k cache write ($0.54)
claude-haiku-4-5: 266 input, 19.6k output, 746.1k cache read, 168.3k cache write ($0.3830)
claude-opus-4-7: 532 input, 8.9k output, 1.0m cache read, 65.9k cache write ($1.15)
basically command run is the most expensive thing here.
When running session on opus46, command on opus47, and subagents on haiku:
Total cost: $1.58
Total duration (API): 5m 17s
Total duration (wall): 2m 27s
Total code changes: 121 lines added, 0 lines removed
Usage by model:
claude-opus-4-7: 528 input, 2.7k output, 108.1k cache read, 72.0k cache write ($0.57)
claude-haiku-4-5: 253 input, 18.9k output, 715.9k cache read, 160.5k cache write ($0.3671)
claude-opus-4-6: 356 input, 4.9k output, 447.8k cache read, 46.9k cache write ($0.64)
Same thing here, just cheaper.
This should be fixed or properly explained in the documentation.
What Should Happen?
I should see usages by command and subagents models, not by session model.
Error Messages/Logs
no
Steps to Reproduce
- make a command running subagents and specify opus-A
- make subagent using haiku
- start a session, switch to opus-B
- run the command
- cost shows strange numbers for the session model
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.143
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗