Skip to content

[Bug]: Usage Tokens view calculates Share using cost instead of token count #14427

Description

@siddharthrajguru

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Usage dashboard / model breakdown (observed with OpenCode usage)

Steps to reproduce

  1. Use OpenCode with at least two models with substantially different API-equivalent pricing.
  2. Accumulate usage for both models.
  3. Open Usage and select Tokens.
  4. Compare each model's token count with its displayed Share percentage.
  5. Switch to Cost and compare the Share percentages.

Expected behavior

Share should correspond to the selected metric:

  • Cost: model cost / total cost
  • Tokens: model tokens / total tokens

Actual behavior

Observed OpenCode usage:

Model Tokens Estimated cost
gpt-5.6-sol ~289M ~$165.21
gpt-5.6-luna ~92.7M ~$3.53
Total ~382M ~$168.74

In Tokens mode, Share displays approximately:

  • Sol: 97.9%
  • Luna: 2.1%

The actual token shares are approximately:

  • Sol: 75.7%
  • Luna: 24.3%

The displayed 97.9% / 2.1% instead matches the cost distribution (Luna: $3.53 / $168.74 ≈ 2.1%).

This suggests Share is calculated from cost even when Tokens is selected.

Impact

Token totals themselves appear correct, but the model Share column is misleading. In this example Luna accounts for roughly one quarter of tokens while Tokens mode reports only 2.1%.

Provider

OpenCode. Reproduced with gpt-5.6-sol and gpt-5.6-luna.

This may affect other providers if the Usage UI shares the same calculation path.

Suggested regression coverage

Use two model rows where token share differs significantly from cost share and assert that switching Cost ↔ Tokens recomputes Share from the selected metric.

Workaround

Calculate token share manually from the displayed token counts.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions