Skip to content

fix(analytics): report shows lower spending than Claude Code /statusline for the same session - #492

Open
kostiantyn-pshenychnyi1 wants to merge 1 commit into
codemie-ai:mainfrom
kostiantyn-pshenychnyi1:EPMCDME-14267
Open

fix(analytics): report shows lower spending than Claude Code /statusline for the same session#492
kostiantyn-pshenychnyi1 wants to merge 1 commit into
codemie-ai:mainfrom
kostiantyn-pshenychnyi1:EPMCDME-14267

Conversation

@kostiantyn-pshenychnyi1

Copy link
Copy Markdown
Contributor

Summary

The statusline displayed the session cost Claude Code calculates and passes in its payload — a figure CodeMie could not reconcile against tenant billing. CodeMie now computes it from the tenant's own per-token rates served by /v1/llm_models, falling back to Claude Code's value when those rates are unavailable.

Refs: EPMCDME-14267

Changes

  • Add plugin/transcript-cost.mjs — per-model session cost, counting each API response once.
  • Fetch tenant rates from /v1/llm_models, cached per tenant in ~/.codemie/model-prices-cache.json (6h TTL).
  • Limit the fetch to gateway-billed providers (ai-run-sso, jwt, litellm, bedrock); subscription providers point at the vendor's API, not a CodeMie host.
  • statusline-installer.ts now generates the deployed script, inlining the cost module — it runs standalone from ~/.claude and cannot import from the package.

Testing

  • Tests added/updated (40 new)
  • Manual testing done — verified against a live tenant on both a gateway and a subscription profile

Checklist

  • Code follows project standards
  • CI is green (npm run ci) — unit tests (3120), typecheck, and lint pass locally; full npm run ci not run yet
  • No merge conflicts with main

Notes

  • The displayed cost changes: Claude Code's figure counted some API responses more than once.
  • codemie analytics still prices from src/utils/pricing.json (Anthropic list rates), so on a gateway tenant it reads below the statusline. Follow-up, not in this PR.

…ine for the same session

The statusline displayed the session cost Claude Code calculates and passes
in its payload, which CodeMie could not reconcile against tenant billing.
CodeMie now computes it from the tenant's own per-token rates served by
/v1/llm_models, falling back to Claude Code's value when rates are
unavailable.

Refs: EPMCDME-14267

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
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.

1 participant