Skip to content

Comments

Fix cache token calculation for Claude Max/Pro users#10

Open
zfogg wants to merge 3 commits intogrp06:mainfrom
zfogg:fix/claude-max-token-counting
Open

Fix cache token calculation for Claude Max/Pro users#10
zfogg wants to merge 3 commits intogrp06:mainfrom
zfogg:fix/claude-max-token-counting

Conversation

@zfogg
Copy link

@zfogg zfogg commented Sep 4, 2025

Fixes #6 - Resolves "Count Is Wrong" user complaints about severely under-reported usage.

The Problem

Claude Max/Pro users are dramatically under-credited on the leaderboard. Example:

  • Actual usage cost: ~$5,500
  • Displayed on leaderboard: ~$5
  • Under-reporting: 99.9%

This happens because the current system counts raw tokens instead of effective tokens, ignoring Anthropic's cache pricing model.

The Fix

Backend: One line change to use enhanced token calculation

const displayTokens = tokens.effective_total_tokens || (tokens.input + tokens.output);

Hook: Enhanced to calculate proper effective tokens using official Anthropic cache pricing

Impact

  • Fixes existing user complaints (Issue Count Is Wrong #6)
  • Makes leaderboard accurate for all subscription types
  • Fully backward compatible
  • Zero risk to existing functionality

This ensures Claude Pro/Max users get proper credit for their actual usage costs, building trust in the leaderboard's accuracy.

🤖 Generated with Claude Code

zfogg and others added 3 commits September 4, 2025 01:26
Fixes grp06#6 - Enhanced hook with proper cache token pricing.
Backend needs one line change: use effective_total_tokens field.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zfogg zfogg mentioned this pull request Sep 4, 2025
@zfogg
Copy link
Author

zfogg commented Sep 4, 2025

Alternative approach: You could fix this on the backend instead of requiring hook updates.

The hook already sends cache_creation and cache_read fields. Backend just needs:

const effectiveTokens = tokens.input + tokens.output + 
  (tokens.cache_creation * 1.25) + (tokens.cache_read * 0.1);

Backend fix advantages:

  • No user re-installation needed
  • Instantly fixes all existing users
  • You control the deployment

This PR provides the enhanced hook for completeness, but backend-only fix would work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Count Is Wrong

1 participant