Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(usage): price Cursor cache savings by base model #13731

MergedYash-Singh1(GitHub profile, opens in a new tab)merged 1 commit intomain fromfix/cursor-usage-cache-savingsmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

What Changed

Cursor usage records now map tiered model names to their base model rate key. Cost and cache savings use that rate while provider-reported costs remain unchanged.

Why

Cursor model names include tier and speed suffixes that do not match the pricing table keys. Mapping them to the base model lets cache savings use the correct rate.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Summary by CodeRabbit

  • Bug Fixes
    • Cursor usage costs and cache savings now use matching base-model rates for recognized Claude and Grok variants, including names with tier or speed suffixes.
    • When a provider reports a cost for a model variant, that reported cost is used. Models without a matching rate continue to show no cache savings.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This focused server change remaps Cursor’s tiered model names to base pricing keys and changes displayed usage pricing and cache-savings calculations. Because it directly affects production usage metering/pricing, it requires human review despite its limited scope.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.5 KiB−15 B (−0.1%)15.1 KiB✅
      CodexThread snapshot wire7.1 KiB7.1 KiB−4 B (−0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB−11 B (−0.2%)7.8 KiB✅
      CodexLive turn WebSocket decoded56.2 KiB56.2 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages990 (0.0%)21✅
      ClaudeTotal thread wire13.5 KiB13.5 KiB−4 B (−0.0%)15.1 KiB✅
      ClaudeThread snapshot wire7.1 KiB7.1 KiB−3 B (−0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB−1 B (−0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: ed809f7 · PR result: 5c77e7d · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 114.0 KiB
      • Claude decoded thread snapshot: 114.7 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Team

      Run ID: c2eef35d-37c7-4867-b174-3d6ee8f94bca

      📥 Commits

      Reviewing files that changed from the base of the PR and between ed809f7ad274ebccdfbf029ccfd7ff2582fd486a and 5c77e7dec14bbc23e9cc798c2a1315c53ee5fd94.

      📒 Files selected for processing (4)
      • apps/server/src/usage/cursorUsageReader.ts
      • apps/server/src/usage/usagePricing.test.ts
      • apps/server/src/usage/usagePricing.ts
      • apps/server/src/usage/usageTranscripts.ts

      Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.


      📝 Walkthrough

      Walkthrough

      Cursor usage records now include a normalized rate-model key. Pricing and cache-savings calculations use that key for rate-table lookups when it is present, and otherwise use the displayed model name.

      Changes

      Cursor rate-model pricing

      Layer / File(s)Summary
      Define and populate rateModel
      apps/server/src/usage/usageTranscripts.ts, apps/server/src/usage/cursorUsageReader.ts
      UsageRecord adds an optional rateModel. Cursor records populate it with a normalized model name.
      Use rateModel for pricing lookups
      apps/server/src/usage/usagePricing.ts, apps/server/src/usage/usagePricing.test.ts
      Rate-table lookups for usage pricing and cache savings use rateModel when present, otherwise model. Tests cover Cursor model variants, cache savings, and provider-reported cost precedence.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: t3dotgg

      Merge Risk: ⚪ Minimal · up to 5c77e

      Cursor usage pricing is ready to merge after normal checks; no actionable pricing regression was established.

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly identifies the primary change: pricing Cursor cache savings by the base model.
      Description check✅ PassedThe description explains what changed and why, confirms the PR is focused, and does not require UI details because the changes are server-side.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches 💡 1
      📝 Generate docstrings 💡
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.