Skip to content

Usage reporting shows misleading 0% windows for enterprise/usage-based Anthropic seats #924

Description

@mfeckie

Problem

Enterprise and usage-based Anthropic seats return null for five_hour, seven_day and seven_day_opus in the OAuth usage payload. jcode coerces those nulls to 0.0 and renders:

5-hour window: 0%
7-day window: 0%

That is actively misleading: it looks like a fully idle subscription when the account has no rolling windows at all.

The real quota for those seats lives in dollar-denominated fields the parser drops on the floor: rotating code-named objects (e.g. cinder_cove with limit_dollars / used_dollars / resets_at) plus the extra_usage credit pool.

Knock-on effect: exhaustion and account-failover logic treats such an account as 0% used, so it never fails over.

Fix

I have a patch that:

  • tracks whether each rolling window was actually reported
  • captures spend/credit limits from the unknown-key part of the payload
  • omits unreported windows from /usage and the info widget, showing spend limits with dollar amounts instead
  • notes the plan type so an empty window list is explained rather than silently blank
  • adds UsageData::windows_exhausted() / spend_exhausted() and uses them for exhaustion and failover decisions

Verified against a live enterprise account, which now reports:

Spend limit (cinder_cove) ($1000.00 of $1000.00) = 100%
Extra usage credits ($16803.00 of $17500.00) = 96%

instead of two 0% bars. Subscription accounts still report 5-hour/7-day windows unchanged. Tests added in crates/jcode-base/src/usage/tests.rs.

Branch

I could not open a PR ("An owner of this repository has limited the ability to open a pull request to users that are collaborators on this repository"), so the commit is on my fork:

https://github.com/mfeckie/jcode/tree/fix/enterprise-usage

Compare: master...mfeckie:jcode:fix/enterprise-usage

Happy to open a PR if you'd like to grant access, otherwise feel free to cherry-pick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions