[BUG] `total_cost_usd` inflated ~2x on Fable 5 sessions with refusal fallbacks — one session reported $1,175 while the entire org's dashboard day was $643

Open 💬 0 comments Opened Jul 4, 2026 by ekaj2

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?

[BUG] total_cost_usd inflated ~2x on Fable 5 sessions with refusal fallbacks — one session reported $1,175 while the entire org's dashboard day was $643

Bug Description

The total_cost_usd field in the result event (--print --output-format stream-json) massively over-reports cost for claude-fable-5 sessions in which the safety classifier triggered model_refusal_fallback to claude-opus-4-8.

A single ~37-minute session reported total_cost_usd: 1175.13. The Anthropic Console cost dashboard for the same day, across our entire organization and all API keys, shows $642.76 total (Claude Fable 5: $317.85, Claude Opus 4.8: $274.55, all other models < $51). One session cannot cost more than the whole org's daily spend — the reported figure is inflated at least ~2x.

Environment

  • Claude Code CLI version: 2.1.201 (entrypoint: sdk-cli)
  • Platform: Linux (Ubuntu 24.04)
  • Invocation: claude --print --output-format stream-json, with --continue between prompts
  • Model: claude-fable-5 (API key / pay-as-you-go)

The session

  • Long agentic run: 148 assistant messages in the main loop plus 17 subagents (Agent tool), analyzing ~460 screenshots. Total wall time ~37 min.
  • Between 21:21 and 21:37 UTC the stream emitted six assistant events containing a fallback content block (claude-fable-5claude-opus-4-8) — the safety classifier repeatedly declined benign medical-software training content and fell back to Opus 4.8.
  • Consistent with #67009, after falling back the session appears to have been substantially served by Opus 4.8 — our Console dashboard shows a near 50/50 Fable/Opus split for the day.

Numbers

Final result event:

{
  "total_cost_usd": 1175.13217925,
  "duration_ms": 968319,
  "usage": {
    "input_tokens": 34225,
    "output_tokens": 50585,
    "cache_creation_input_tokens": 218995,
    "cache_read_input_tokens": 7996258
  }
}

Summing usage across all 148 assistant messages in the session transcript (main loop only, subagents excluded):

| | tokens |
|---|---|
| input | 131,972 |
| output | 169,666 |
| cache_creation | 509,334 |
| cache_read | 16,373,615 |

At published Fable 5 rates ($10/$50 per MTok, cache write ~$12.50, cache read ~$1), the main loop works out to ~$33. Even with very generous estimates for the 17 subagents (each reading 33–47 images across multiple turns), token-rate math lands in the low hundreds of dollars — consistent with the ~$590 Fable+Opus total on the dashboard, and nowhere near $1,175.

Expected vs Actual

  • Expected: total_cost_usd ≈ what the Console cost dashboard bills for the session, with fallback-served tokens priced at the fallback model's rates and declined-before-output attempts unbilled.
  • Actual: total_cost_usd = $1,175.13 — more than the entire organization's dashboard spend for the day ($642.76).

Suspected root cause

Client-side cost computation prices all turns at the requested model's rates (claude-fable-5, $10/$50) rather than the model that actually served them after a refusal fallback (claude-opus-4-8, $5/$25 — exactly 2x cheaper). The server-side fallback semantics also reprice retries with fallback credits and don't bill declined-before-output attempts; a naive per-token computation keyed to the requested model would miss all of that.

This would be the same class of bug as:

  • #28168 — cost metric applied Opus pricing to Sonnet 4.6 tokens (1.67x high; reporter proved the wrong price-map entry from the binary)
  • #64701 — price map wrong in 2.1.159, claude-opus-4-8 billed 3x high

And the same symptom as #53371 / #51198 (inflated total_cost_usd / cost_report, both closed without a fix).

Impact

We surface total_cost_usd to users for per-session cost accounting. A 2x+ error on the exact sessions that hit refusal fallbacks (which per #66657 / #67305 / #73362 fire on plenty of benign work) makes the field unusable, and the inflated figures alarm users into thinking runs cost 2x+ what they do.

Workaround

Ignoring total_cost_usd and computing from per-message usage with a per-serving-model price map.

What Should Happen?

See above.

Error Messages/Logs

See above.

Steps to Reproduce

See above.

Claude Model

Other

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.201

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

_No response_

View original on GitHub ↗