claude-code - 💡(How to fix) Fix [BUG] Unexpected session model tokens usage for opus [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#60529Fetched 2026-05-20 03:56:13
View on GitHub
Comments
3
Participants
2
Timeline
12
Reactions
0
Author
Participants
Timeline (top)
labeled ×5commented ×3mentioned ×2subscribed ×2

Error Message

Error Messages/Logs

Code Example

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)

---

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)

---

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)

---

no
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Unexpected session model tokens usage for opus [3 comments, 2 participants]