Skip to content

fix(pi): honor pricing overrides in auto cost mode - #1816

Merged
ryoppippi merged 2 commits into
mainfrom
fix/pi-pricing-overrides-auto
Oct 2, 2026
Merged

ryoppippi merged 2 commits into
mainfrom
fix/pi-pricing-overrides-auto

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Pi's Auto cost mode preferred the session's stored usage.cost.total over explicit pricingOverrides, leaving custom gateway models at $0.00. Use the override for the prefixed or bare model name, including configured aliases, to calculate token costs for default and named Pi stores. Display mode still shows the recorded cost, and models without overrides retain their existing cost handling. Add regression coverage and document the override keys and cost modes.

Closes #1810

Validation:

  • just check: all 11 Nix flake checks passed on this Mac
  • just fmt and cargo fmt --all --manifest-path rust/Cargo.toml --check
  • just typecheck
  • just test: 947 Rust tests and 34 Node tests passed; 3 existing Rust tests ignored
  • cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warnings
  • just hawk: 0 findings
  • 16 CLI smoke checks covering config scopes, daily/monthly/session JSON and tables, and Auto/Calculate/Display behavior

CI is blocked by existing tirith findings in unchanged files: the base and PR commit both produce the same 17 findings (8 errors and 9 warnings) with tirith 0.4.2. Downstream tests and native builds were skipped; see the CI run.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: be265e09-39c3-4eba-b24c-cd16ae9cfbb4

📥 Commits

Reviewing files that changed from the base of the PR and between 065e099 and c9630c4.

📒 Files selected for processing (5)
  • docs/guide/config-files.md
  • docs/guide/pi/index.md
  • rust/adapters/pi/src/README.md
  • rust/adapters/pi/src/parser.rs
  • rust/crates/ccusage-core/src/pricing.rs
 _________________________________________
< Digging deeper than a Minecraft player. >
 -----------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide c9630c4 Commit Preview URL

Branch Preview URL
Oct 02 2026, 06:31 PM

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ccusage/ccusage-darwin-arm64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-arm64@1816

@ccusage/ccusage-darwin-x64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-x64@1816

@ccusage/ccusage-linux-arm64

npx https://pkg.pr.new/@ccusage/ccusage-linux-arm64@1816

@ccusage/ccusage-linux-x64

npx https://pkg.pr.new/@ccusage/ccusage-linux-x64@1816

@ccusage/ccusage-win32-x64

npx https://pkg.pr.new/@ccusage/ccusage-win32-x64@1816

ccusage

npx https://pkg.pr.new/ccusage@1816

commit: c9630c4

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: c9630c458e29
Base SHA: 065e09981839

This compares the PR package against the configured base package on the same CI runner.

Package runtime diagnostics

Compares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself.

Fixtures: Claude /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 424.8ms 2.37 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 374.4ms 2.69 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 137.3ms 7.33 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 113.5ms 8.87 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 64.8ms 68.3ms 0.95x 55.75 MiB 55.75 MiB 1.00x 0.02 MiB/s 0.02 MiB/s
claude session --offline --json 0.00 MiB 60.1ms 59.3ms 1.01x 55.75 MiB 55.50 MiB 1.00x 0.03 MiB/s 0.03 MiB/s
codex daily --offline --json 0.00 MiB 35.5ms 37.1ms 0.96x 55.75 MiB 55.50 MiB 1.00x 0.02 MiB/s 0.02 MiB/s
codex session --offline --json 0.00 MiB 33.3ms 36.3ms 0.92x 55.50 MiB 56.00 MiB 1.01x 0.03 MiB/s 0.02 MiB/s

Large real-world-shaped fixture performance

Generated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures.

Fixtures: Claude /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 411.4ms 419.4ms 0.98x 913.07 MiB 933.09 MiB 1.02x 2.45 GiB/s 2.40 GiB/s
codex --offline --json 1.01 GiB 164.8ms 146.0ms 1.13x 451.41 MiB 435.42 MiB 0.96x 6.11 GiB/s 6.90 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 23.69 KiB 23.69 KiB -0.00 KiB 1.00x
installed native package binary 4640.41 KiB 4641.03 KiB +0.63 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: c9630c458e29
Base SHA: 065e09981839

This compares the Rust PR release binary against the configured base package on the same CI runner.

Package runtime diagnostics

Compares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself.

Fixtures: Claude /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 394.8ms 2.55 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 374.5ms 2.69 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 132.5ms 7.60 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 107.2ms 9.39 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 42.0ms 18.4ms 2.28x 55.50 MiB 22.97 MiB 0.41x 0.04 MiB/s 0.08 MiB/s
claude session --offline --json 0.00 MiB 40.6ms 11.4ms 3.58x 55.75 MiB 22.97 MiB 0.41x 0.04 MiB/s 0.14 MiB/s
codex daily --offline --json 0.00 MiB 33.8ms 11.2ms 3.03x 55.50 MiB 23.21 MiB 0.42x 0.03 MiB/s 0.08 MiB/s
codex session --offline --json 0.00 MiB 34.2ms 10.7ms 3.19x 55.50 MiB 23.21 MiB 0.42x 0.03 MiB/s 0.08 MiB/s

Large real-world-shaped fixture performance

Generated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures.

Fixtures: Claude /home/runner/_work/_temp/ccusage-large-fixture (1.01 GiB, 2597 files), Codex /home/runner/_work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published native ccusage binary from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 421.7ms 385.1ms 1.10x 943.09 MiB 935.10 MiB 0.99x 2.39 GiB/s 2.61 GiB/s
codex --offline --json 1.01 GiB 144.8ms 117.9ms 1.23x 435.42 MiB 437.42 MiB 1.00x 6.95 GiB/s 8.54 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 23.69 KiB 23.69 KiB -0.00 KiB 1.00x
installed native package binary 4640.41 KiB 4641.03 KiB +0.63 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@ryoppippi
ryoppippi marked this pull request as ready for review October 2, 2026 20:09
@ryoppippi
ryoppippi merged commit 4140725 into main Oct 2, 2026
36 checks passed
@ryoppippi
ryoppippi deleted the fix/pi-pricing-overrides-auto branch October 2, 2026 20:10
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — reviewed head c9630c4 of PR #1816 against main, covering the Pi auto-mode pricing-override fix and its docs/tests.

  • Pi auto-mode override precedence — pricing_override_model plus source_cost_for_mode now suppress the recorded usage.cost.total when an override exists for the prefixed or bare model name, recalculating from tokens.
  • Store-aware pricing lookup — store_pricing / store_pricing_at resolve the override key first via find / find_at, keeping exact-match behavior for non-override display models.
  • Missing-pricing reporting — missing_pricing_model paths use the override-resolved model with the suppressed source cost, so overridden custom models no longer surface as missing or silently cost $0.00.
  • PricingMap::has_user_override — new helper checks the override map directly and through CCUSAGE_MODEL_ALIASES, with alias-resolution test coverage.
  • Regression tests and docs — exact-cost assertions (5.0 recalculated vs 0.0 recorded) for default, named-store, and bare-key cases, plus override-key and cost-mode documentation.

The override precedence (prefixed display label wins over bare raw name), bare-key sharing across default and named stores, and unchanged display-mode behavior all match the documented intent. The new tests assert exact values that fail pre-fix, so they pin the behavior rather than absorbing it.

Pullfrog  | View workflow run | Using muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏

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.

pricingOverrides is silently ignored for the pi subcommand (works correctly for claude)

1 participant