Skip to content

fix(usage): correct replay and pricing accounting - #1438

Merged
ryoppippi merged 12 commits into
ccusage:mainfrom
camjac251:fix/pricing-aliases
Jul 26, 2026
Merged

ryoppippi merged 12 commits into
ccusage:mainfrom
camjac251:fix/pricing-aliases

Conversation

@camjac251

@camjac251 camjac251 commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Correct usage reports that can count inherited child-session history more than once, and fix pricing paths involving recorded speed tiers, default family aliases, and partial overrides.

Recent rollouts now preserve explicit Fast and Standard settings per request. Auto mode honors those records, falls back to configuration only for unclassified usage, and explicit speed flags override the complete report.

What Changed

  • exclude inherited parent-history prefixes from current child-session usage
  • retain timestamp-based compatibility handling for older replay formats
  • suppress repeated request deltas when cumulative totals do not advance
  • preserve usage produced by the child around the durable turn boundary
  • apply recorded Fast and Standard changes chronologically
  • reset inherited parent settings at the child turn boundary
  • reconcile tier metadata across copied records without double-counting tokens
  • resolve conflicting duplicate tier metadata deterministically at Standard
  • centralize date filtering and period selection across totals and recorded-tier attribution
  • price mixed speed and long-context request buckets independently
  • add documented priority multipliers for the three current family variants
  • require an explicit multiplier before adjusting speed-tier costs
  • resolve known family aliases before fuzzy pricing and context lookup
  • preserve exact overrides and merge partial overrides onto canonical pricing
  • update command help and usage documentation for recorded-tier behavior
  • keep golden snapshots reviewable as text

Notes

  • Report schemas and table layouts are unchanged.
  • Unclassified startup, legacy, and headless usage still uses configuration fallback.
  • Unknown speed-tier rates remain at the standard estimate until an explicit multiplier is available.
  • All committed fixtures use synthetic identifiers, timestamps, paths, and token values.
  • No local source records or user-specific data are included.

Verification

  • full repository suite: 374 main tests, 11 schema tests, 61 command tests, 16 terminal tests, 14 package tests, plus support and documentation tests
  • flake checks: formatting, type-aware lint, warnings-as-errors lint, schema drift, package lint, and repository secret scan
  • focused source tests: 66 passed
  • Markdown lint and staged diff checks
  • signed commits and staged secret scans
  • static package launch and Auto/Standard/Fast smoke comparison
  • completed three-day output parity and performance comparison against the prior implementation

Related: #1434, #1436

Summary by CodeRabbit

  • New Features
    • Codex usage reports now capture and apply recorded Standard/Fast service tiers from session rollout events, including improved --speed auto behavior over time.
  • Bug Fixes
    • Deduplication is now deterministic and preserves conflicting tier metadata correctly.
    • Fast pricing no longer relies on an implicit 2× fallback when fast multiplier data is missing.
    • Pricing/model aliases (including GPT-5.6 variants and Kindle) resolve more consistently, with correct long-context split behavior.
  • Documentation
    • Updated the Codex guide with refined token-delta and speed-pricing descriptions; added session classification notes.
  • Tests
    • Expanded regression coverage for tier parsing, classification, and pricing outcomes.

Fast pricing previously doubled usage whenever a model lacked a known
multiplier, which turned missing rate data into an unsupported estimate.

Apply only explicit multipliers, keep unknown rates at standard pricing,
refresh the report snapshot, and remove the obsolete timing-inference
scratch plan.
A global package-file rule can classify Rust golden snapshots as binary,
hiding reviewable output changes.

Override that classification only under snapshot directories while leaving
actual package archives binary.
The unsuffixed family alias matched the longest sibling key and selected
the balanced tier rather than the documented flagship tier.

Preserve exact user overrides, resolve canonical aliases before fuzzy
fallback, and apply the same mapping to context limits and request-tier
thresholds. Partial overrides now inherit unspecified canonical rates.
Current subagent rollouts can persist copied parent snapshots before
the child's first turn. Treating those cumulative records as fresh
usage compounds totals across nested sessions.

Use the durable turn boundary for current logs, retain the timestamp
fallback for older formats, and suppress unchanged cumulative
snapshots while preserving child deltas.
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3345f722-5fce-4e5b-b1ef-14441bd5f712

📥 Commits

Reviewing files that changed from the base of the PR and between 3f35031 and 154db13.

📒 Files selected for processing (1)
  • rust/crates/ccusage/src/adapter/codex/loader.rs

📝 Walkthrough

Walkthrough

Codex parsing now records service tiers and replay metadata. Tier-aware deduplication and aggregation preserve standard, fast, and long-context usage for cost reporting. Pricing aliases, multipliers, documentation, CLI help, and snapshot attributes were updated.

Changes

Codex and pricing updates

Layer / File(s) Summary
Codex replay and service-tier parsing
rust/crates/ccusage/src/adapter/codex/types.rs, rust/crates/ccusage/src/adapter/codex/parser.rs, rust/crates/ccusage/src/adapter/codex/loader.rs
Session settings populate service tiers on token events; replay and deduplication regressions cover fork boundaries, fallback, and copied history.
Recorded-tier aggregation and deduplication
rust/crates/ccusage/src/types.rs, rust/crates/ccusage/src/adapter/codex/aggregate.rs
Usage buckets preserve standard and fast recorded totals, including long-context splits, across deduplication and parallel aggregation.
Speed policy and cost reporting
rust/crates/ccusage/src/adapter/codex/speed.rs, rust/crates/ccusage/src/adapter/codex/report.rs, rust/crates/ccusage/src/adapter/all/loader.rs, rust/crates/ccusage/src/adapter/codex/mod.rs, rust/crates/ccusage/src/main.rs
Cost calculations use explicit speed policies and recorded buckets, with standard pricing when no fast multiplier exists.
Canonical pricing and supporting updates
rust/crates/ccusage/src/pricing.rs, rust/crates/ccusage/src/fast-multiplier-overrides.json, rust/crates/ccusage-cli/src/cli-help.json, docs/guide/codex/index.md, rust/crates/ccusage/src/adapter/codex/README.md, .gitattributes
Alias resolution, overrides, long-context thresholds, model multipliers, help text, documentation, and snapshot handling were updated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SessionLog
  participant CodexParser
  participant CodexAggregator
  participant CostReporter
  SessionLog->>CodexParser: Read thread settings and token events
  CodexParser->>CodexAggregator: Emit tier-tagged usage events
  CodexAggregator->>CostReporter: Provide deduplicated standard/fast buckets
  CostReporter->>CostReporter: Apply speed policy and pricing
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers: pullfrog, ryoppippi

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change set: replay accounting and pricing/usage accounting fixes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Recent rollouts persist explicit Fast and Standard settings. Preserve
those transitions during parsing so mixed-mode reports apply published
rates only to matching requests.

Reconcile copied records before attributing tier buckets so file order
and worker scheduling cannot change cost estimates. Command-line
overrides remain authoritative, with config used only for unclassified
usage.
Copilot AI review requested due to automatic review settings July 23, 2026 02:22

Copilot AI 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.

Pull request overview

Fixes Codex usage/cost accounting regressions by (1) preventing replayed parent-history from being double-counted in MultiAgent V2 subagent sessions, and (2) tightening pricing resolution so speed-tier multipliers and model-family aliases are applied only when explicitly defined—while preserving exact and partial overrides.

Changes:

  • Correct Codex replay/subagent accounting by establishing a child-session baseline, skipping non-advancing cumulative snapshots, and counting only the child’s advancing usage (including around the durable turn boundary).
  • Introduce recorded per-event Codex service tier tracking (Standard/Fast) and apply mixed-tier pricing in --speed auto, with explicit fast multipliers required before adjusting costs.
  • Improve pricing lookups by resolving canonical family aliases (notably gpt-5.6 → gpt-5.6-sol) before fuzzy matching, and ensuring overrides merge onto canonical base entries.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/crates/ccusage/src/types.rs Adds Codex service-tier and bucket types plus deterministic tier-merge logic for deduped events.
rust/crates/ccusage/src/pricing.rs Adjusts alias/exact/fuzzy resolution order; canonicalizes alias use for context limits and long-context thresholds; adds tests for alias + override precedence.
rust/crates/ccusage/src/main.rs Updates test fixtures to include the new service_tier field.
rust/crates/ccusage/src/fast-multiplier-overrides.json Adds explicit fast multipliers for GPT‑5.6 Sol/Terra/Luna.
rust/crates/ccusage/src/adapter/codex/types.rs Extends decoded payload schema to capture thread settings / service tier markers and related metadata.
rust/crates/ccusage/src/adapter/codex/speed.rs Introduces CodexSpeedPolicy (auto vs forced) and maps CLI speed selections into tier policy.
rust/crates/ccusage/src/adapter/codex/snapshots/ccusage__adapter__codex__tests__snapshots_codex_reports_for_periods_sessions_costs_and_fallback_models.snap Updates golden outputs to reflect corrected cost calculations.
rust/crates/ccusage/src/adapter/codex/report.rs Implements mixed-tier pricing by splitting recorded standard/fast usage and applying multipliers only where defined.
rust/crates/ccusage/src/adapter/codex/README.md Documents the new thread_settings_applied service-tier markers and how they influence auto pricing.
rust/crates/ccusage/src/adapter/codex/parser.rs Reworks replay handling (subagent marker vs timestamp fallback), skips non-advancing totals, and records service tier transitions.
rust/crates/ccusage/src/adapter/codex/mod.rs Uses resolved speed policy for production runs; keeps test helper wiring updated.
rust/crates/ccusage/src/adapter/codex/loader.rs Dedupes events while preserving/merging service-tier metadata; adds regression tests around tier transitions and replay behavior.
rust/crates/ccusage/src/adapter/codex/aggregate.rs Stores service-tier metadata alongside dedupe keys and reapplies recorded-tier usage into aggregated model buckets deterministically.
rust/crates/ccusage/src/adapter/all/loader.rs Ensures unified “all agents” rows compute Codex costs consistently with mixed recorded tiers.
rust/crates/ccusage-cli/src/snapshots/ccusage_cli__tests__codex_daily_help.snap Updates CLI help snapshot to reflect new --speed auto behavior description.
rust/crates/ccusage-cli/src/cli-help.json Updates generated CLI help JSON for --speed description.
docs/guide/codex/index.md Updates user docs to describe replay baselining, recorded tier tracking, and conservative unknown-fast pricing behavior.
codex-speed-infer-plan.md Removes obsolete inference-plan notes now superseded by recorded-tier support.
.gitattributes Treats Insta .snap files as text with LF endings for consistent diffs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
rust/crates/ccusage/src/adapter/codex/aggregate.rs (1)

414-475: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Period/date-filter logic is duplicated between apply_recorded_usage_entries and add_deduped_event_to_groups.

The since/until compaction check and the match kind { Daily/Weekly/Monthly/Session } period selection here are a copy of the logic in add_deduped_event_to_groups (Lines 309-323). Since recorded buckets are attributed independently of the totals accumulation, any future divergence between these two blocks would silently misattribute recorded_standard_usage/recorded_fast_usage to a period the totals don't share, without a compile error. Consider extracting a shared codex_period_for(timestamp, session_id, kind, shared, timezone) -> Option<String> helper used by both paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/crates/ccusage/src/adapter/codex/aggregate.rs` around lines 414 - 475,
Extract the duplicated date filtering and period selection from
add_deduped_event_to_groups and apply_recorded_usage_entries into a shared
codex_period_for helper returning Option<String>. Pass the event timestamp,
optional session ID, report kind, shared date bounds, and timezone; preserve the
existing Daily, Weekly, Monthly, and Session behavior, including returning None
for out-of-range dates or missing session IDs, and use the helper in both paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@rust/crates/ccusage/src/adapter/codex/aggregate.rs`:
- Around line 414-475: Extract the duplicated date filtering and period
selection from add_deduped_event_to_groups and apply_recorded_usage_entries into
a shared codex_period_for helper returning Option<String>. Pass the event
timestamp, optional session ID, report kind, shared date bounds, and timezone;
preserve the existing Daily, Weekly, Monthly, and Session behavior, including
returning None for out-of-range dates or missing session IDs, and use the helper
in both paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 019f9d96-f3d6-42f6-be32-17aaf13039d2

📥 Commits

Reviewing files that changed from the base of the PR and between 31e084a and 65e8005.

⛔ Files ignored due to path filters (2)
  • rust/crates/ccusage-cli/src/snapshots/ccusage_cli__tests__codex_daily_help.snap is excluded by !**/*.snap
  • rust/crates/ccusage/src/adapter/codex/snapshots/ccusage__adapter__codex__tests__snapshots_codex_reports_for_periods_sessions_costs_and_fallback_models.snap is excluded by !**/*.snap
📒 Files selected for processing (17)
  • .gitattributes
  • codex-speed-infer-plan.md
  • docs/guide/codex/index.md
  • rust/crates/ccusage-cli/src/cli-help.json
  • rust/crates/ccusage/src/adapter/all/loader.rs
  • rust/crates/ccusage/src/adapter/codex/README.md
  • rust/crates/ccusage/src/adapter/codex/aggregate.rs
  • rust/crates/ccusage/src/adapter/codex/loader.rs
  • rust/crates/ccusage/src/adapter/codex/mod.rs
  • rust/crates/ccusage/src/adapter/codex/parser.rs
  • rust/crates/ccusage/src/adapter/codex/report.rs
  • rust/crates/ccusage/src/adapter/codex/speed.rs
  • rust/crates/ccusage/src/adapter/codex/types.rs
  • rust/crates/ccusage/src/fast-multiplier-overrides.json
  • rust/crates/ccusage/src/main.rs
  • rust/crates/ccusage/src/pricing.rs
  • rust/crates/ccusage/src/types.rs
💤 Files with no reviewable changes (1)
  • codex-speed-infer-plan.md

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 19 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread rust/crates/ccusage/src/adapter/codex/parser.rs Outdated
Totals and recorded-tier buckets previously repeated date filtering and
period grouping independently. Route both paths through one helper so
their daily, weekly, monthly, and session keys cannot drift.
Copilot AI review requested due to automatic review settings July 23, 2026 03:14

Copilot AI 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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

ccusage

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

@ccusage/ccusage-darwin-arm64

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

@ccusage/ccusage-darwin-x64

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

@ccusage/ccusage-linux-arm64

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

@ccusage/ccusage-linux-x64

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

@ccusage/ccusage-win32-x64

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

commit: 3f35031

Recorded speed tiers are written as either "default" or "standard", and
only the first was mapped. The other value was treated as an unknown
tier, which both dropped the classification and cleared the tier that
preceding events had established.

The two spellings are not a version split. They appear in the same
Codex release on the same day, and which one is written depends on the
client rather than the CLI version, so this is a plain value mapping.
Across recorded rollouts only "default", "standard", and "priority"
occur; no other spelling exists to accommodate.

Recognizing "standard" leaves almost all recorded usage classified
instead of falling through to the config-based estimate.
Every thread_settings_applied event overwrote the current tier, even
when it carried no service_tier key at all. Codex emits such events for
auto-review threads, so a rollout that had already recorded a tier lost
it as soon as one of those arrived, and the usage that followed fell
back to the config-based estimate.

An absent key says nothing about the tier, so the previous value now
stands. A tier that is present but unrecognized keeps clearing it,
since that signals a change to something unknown and a stale Fast value
must not be inherited.
Replay handling picked its strategy from session_meta: a subagent
rollout was routed to the turn-marker boundary only when the recorded
thread source, multi-agent version, and CLI version all matched. That
metadata is not trustworthy. Resuming a session re-records the original
session's cli_version, so resumed rollouts are misattributed, and the
gate silently reverts them to the timestamp heuristic.

Worse, the marker path had no floor. Once selected, a rollout whose
marker never appeared buffered every request and discarded the lot at
end of file, reporting zero usage with no warning. The marker was also
renamed upstream, and only the newer spelling was matched, so older
rollouts would have hit exactly that case.

Select the boundary by scanning the rollout instead. A file that
records a turn marker uses it, which still delimits a replay spanning
several seconds; anything else falls back to the repeated-second
heuristic. Both marker spellings are accepted, and trigger_turn is
checked because the event is emitted with either value. The marker
boundary is now only chosen after a marker has actually been seen, so
detection failure can no longer erase a rollout.

Costs are unchanged on real rollouts, including ones that move from the
timestamp path to the marker path, and the added scan is within
measurement noise.
#1435 landed on main and solves replay deduplication the same problem
this branch addressed, but from a better angle: it matches a forked
session's leading events against the immutable parent stream instead of
inferring the boundary from the child log alone.

Resolution takes main's replay implementation wholesale and keeps only
this branch's speed-tier work, which main does not have:

- parser: main's CodexReplayState and replay_prefix plumbing, with
  recorded service tiers threaded back through the session entry visitor
- aggregate: main's CodexAggregateRun and CodexReplayPlan wiring, with
  the recorded-tier dedupe records and bucket attribution kept
- loader: main's replay plan threading, with tier reconciliation kept

The branch's own replay work is dropped as superseded. That also retires
the subagent turn-marker heuristic, its CLI-version gate, and the marker
tests, which is a real improvement: the gate read session_meta
cli_version, a field that resume rewrites from the original session, and
a missing marker discarded a whole rollout. Matching against the parent
stream depends on neither. main's replay tests are carried over intact.

Codex totals are byte-identical to main on real rollouts, and recorded
tiers still classify usage that config fallback would otherwise cover.
Copilot AI review requested due to automatic review settings July 25, 2026 21:11

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ryoppippi

Copy link
Copy Markdown
Member

Merged main to resolve the conflicts, and pushed three follow-up fixes. Summary of what changed and why, since the resolution materially narrows this PR's scope.

Conflict resolution

#1435 landed on main and addresses the same replay double-counting this branch did, but from a better angle: it matches a forked session's leading events against the immutable parent stream rather than inferring the boundary from the child log alone. The resolution takes main's implementation wholesale and keeps only this branch's speed-tier work, which main does not have.

This branch's own replay work is dropped as superseded, which also retires the subagent turn-marker heuristic and its CLI-version gate. That is a real improvement rather than a loss:

  • the gate read session_meta.cli_version, and resuming a session re-records the original session's version, so resumed rollouts were misattributed
  • a missing or renamed marker discarded an entire rollout with no warning, and the marker was in fact renamed upstream (inter_agent_communication → inter_agent_communication_metadata in 0.143.0-alpha.15)

Matching against the parent stream depends on neither. All of main's replay tests are carried over intact.

Follow-up fixes

  • "standard" service tier was dropped as unknown. Recorded tiers are written as either "default" or "standard", and only the first was mapped, so the value was discarded and it cleared the tier established by preceding events. The two spellings are not a version split: they appear in the same release on the same day, and which one is written depends on the client. Across 2,672 real rollouts on two machines only default, standard, and priority occur.
  • A settings event without a service_tier key cleared the tier. Codex emits these for auto-review threads, so a rollout that had recorded a tier lost it. An absent key now leaves the previous value alone; a tier that is present but unrecognized still clears it.

Verification

Against real rollouts, Codex totals are byte-identical to main (844,010,276 input tokens, $12,927.03), including the 15 MultiAgent V2 subagent rollouts (5,007,243 tokens) that exercise the replay path.

The tier fix is what makes the feature actually work. On rollouts that record a tier, with service_tier = "priority" configured:

before after
--speed auto $457.38 $237.06
unclassified share 95.8% 1.5%

(--speed standard $233.65, --speed fast $467.29 for reference.)

Also worth flagging for a follow-up, not changed here: gpt-5.5 carries a 2.5 fast multiplier, while the docs added in this PR describe costUSD as an API-equivalent estimate and call 2.5× the ChatGPT credit-consumption rate. Those two may be inconsistent.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
rust/crates/ccusage/src/adapter/codex/loader.rs (1)

199-259: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover omitted-tier preservation.

Line 199 tests explicit tier transitions, but not the contract where a later thread_settings_applied lacks service_tier and must retain the prior Fast/Standard value. Add a fixture sequence with a recognized tier, an omitted tier field, and a following token event.

As per coding guidelines, “prefer fixture-backed parser/loader tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/crates/ccusage/src/adapter/codex/loader.rs` around lines 199 - 259, Add
a fixture-backed test case alongside
records_service_tier_transitions_for_following_usage that emits a recognized
service tier, then a thread_settings_applied event without service_tier,
followed by token usage. Assert the token event retains the previously
recognized Fast or Standard CodexServiceTier value, covering omitted-tier
preservation through load_codex_events_from_directory.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@rust/crates/ccusage/src/adapter/codex/loader.rs`:
- Around line 199-259: Add a fixture-backed test case alongside
records_service_tier_transitions_for_following_usage that emits a recognized
service tier, then a thread_settings_applied event without service_tier,
followed by token usage. Assert the token event retains the previously
recognized Fast or Standard CodexServiceTier value, covering omitted-tier
preservation through load_codex_events_from_directory.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a9d3749-6517-4df2-befe-5b86dd592203

📥 Commits

Reviewing files that changed from the base of the PR and between 9798c98 and eb82dbf.

📒 Files selected for processing (7)
  • rust/crates/ccusage/src/adapter/codex/README.md
  • rust/crates/ccusage/src/adapter/codex/aggregate.rs
  • rust/crates/ccusage/src/adapter/codex/loader.rs
  • rust/crates/ccusage/src/adapter/codex/mod.rs
  • rust/crates/ccusage/src/adapter/codex/parser.rs
  • rust/crates/ccusage/src/adapter/codex/types.rs
  • rust/crates/ccusage/src/pricing.rs
💤 Files with no reviewable changes (1)
  • rust/crates/ccusage/src/adapter/codex/types.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • rust/crates/ccusage/src/adapter/codex/README.md
  • rust/crates/ccusage/src/adapter/codex/mod.rs
  • rust/crates/ccusage/src/adapter/codex/aggregate.rs
  • rust/crates/ccusage/src/pricing.rs

LiteLLM now ships gpt-5.6 as its own entry. Exact matches win over the
alias, so the bare family name stopped inheriting the Sol variant's
long-context rates and Fast multiplier, and fell back to flat pricing at
a 200K boundary.

Resolve the alias inside the built-in long-context lookup and the Fast
multiplier lookup instead of at individual call sites, so an alias bills
at the variant it points to no matter where upstream data happens to
cover it. That also removes the duplicate alias resolution
long_context_split_threshold was doing.
Copilot AI review requested due to automatic review settings July 25, 2026 21:28

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 25, 2026 23:11

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ryoppippi
ryoppippi force-pushed the fix/pricing-aliases branch from 67db3f4 to 3f35031 Compare July 26, 2026 19:52
Copilot AI review requested due to automatic review settings July 26, 2026 19:52
@cloudflare-workers-and-pages

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 3f35031 Commit Preview URL

Branch Preview URL
Jul 26 2026, 07:48 PM

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ryoppippi

Copy link
Copy Markdown
Member

Correction to my earlier comment: the gpt-5.5 2.5 multiplier is not inconsistent with the docs added here. I was wrong to flag it.

OpenAI's API pricing lists Priority tiers as:

model standard (in/out per 1M) priority multiplier
gpt-5.5 $5 / $30 $12.50 / $75 2.5
gpt-5.6 Sol $5 / $30 $10 / $60 2.0
gpt-5.6 Terra $2.50 / $15 $5 / $30 2.0
gpt-5.6 Luna $1 / $6 $2 / $12 2.0

So gpt-5.5 genuinely bills API Priority at 2.5x; its ChatGPT credit multiplier happens to be the same number. The divergence is on gpt-5.6, where credits are 2.5x but API Priority is 2.0x, and this PR correctly uses 2.0. The multiplier table and the accompanying docs are right as they stand.

One observation rather than a defect: the embedded LiteLLM snapshot carries no provider_specific_entry.fast for any model, so fast-multiplier-overrides.json is currently the only source of these values. Worth knowing if upstream starts publishing them.

@ryoppippi

Copy link
Copy Markdown
Member

@coderabbitai review it

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

@ryoppippi: Reviewing the updated PR scope and follow-up fixes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The loader covered explicit tier transitions and unclassified rollouts,
but not the contract that a thread_settings_applied event carrying no
service_tier key leaves the recorded tier in place. Codex emits exactly
that shape for auto-review threads, so the gap sat on the case the
behaviour exists for.

The fixture also pins the opposite case in the same sequence: a tier
that is present but unrecognized still clears the recorded value.
Copilot AI review requested due to automatic review settings July 26, 2026 20:23

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ryoppippi

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ryoppippi
ryoppippi merged commit 0d968b9 into ccusage:main Jul 26, 2026
14 of 15 checks passed
@ryoppippi

Copy link
Copy Markdown
Member

Historical audit: this pull request was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

Audit result: resolved. A later merged change or the current main implementation covers this request. This PR is kept for history and does not need to be revived.

@ryoppippi ryoppippi added the triage:resolved Resolved by a later change or current implementation. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:resolved Resolved by a later change or current implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants