Skip to content

Fix #503 pricing coverage and unpriced hotspot ranking - #510

Merged
willwashburn merged 4 commits into
mainfrom
issue-503-unpriced-models
Aug 3, 2026
Merged

Fix #503 pricing coverage and unpriced hotspot ranking#510
willwashburn merged 4 commits into
mainfrom
issue-503-unpriced-models

Conversation

@willwashburn

@willwashburn willwashburn commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #503

The vendored models.dev snapshot now includes pricing for claude-opus-5, claude-sonnet-5, gpt-5.6-sol, gpt-5.6-luna, and gpt-5.6-terra. The snapshot comes from the sanctioned models.dev API refresh path.

Pricing flattening gives Anthropic, OpenAI, Google, Google Vertex, and xAI first-party tariffs precedence over duplicate reseller entries, preventing provider file order from silently replacing canonical rates or reasoning semantics. Context-based pricing tiers are preserved and applied when a turn exceeds the provider threshold, including the higher long-context GPT-5.6 rates.

Hotspot findings now emit one explicit unpriced-usage finding per affected session. Unpriced findings carry token volume, sort ahead of priced findings with unknown-price sessions ordered by tokens, render as unpriced in human output, and expose pricingStatus in JSON and Node types without a fake USD estimate. Detector findings from sessions with any unpriced turns also drop partial or zero USD estimates and inherit the visible unpriced status.

Tests cover all five current-generation model IDs, first-party provider precedence, long-context tier selection, token-ranked unpriced findings, detector propagation, JSON status, and the end-to-end hotspot query path.

🤖 Generated with Claude Code.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@willwashburn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 00c04a57-220e-4aff-91e9-d0b8a9908841

📥 Commits

Reviewing files that changed from the base of the PR and between 7dd6114 and a7f292f.

📒 Files selected for processing (16)
  • CHANGELOG.md
  • crates/relayburn-sdk/src/analyze.rs
  • crates/relayburn-sdk/src/analyze/cost.rs
  • crates/relayburn-sdk/src/analyze/findings.rs
  • crates/relayburn-sdk/src/analyze/ghost_surface_inputs.rs
  • crates/relayburn-sdk/src/analyze/hotspots.rs
  • crates/relayburn-sdk/src/analyze/overhead.rs
  • crates/relayburn-sdk/src/analyze/pricing.rs
  • crates/relayburn-sdk/src/analyze/provider.rs
  • crates/relayburn-sdk/src/lib.rs
  • crates/relayburn-sdk/src/query_verbs/hotspots.rs
  • crates/relayburn-sdk/src/query_verbs/mod.rs
  • crates/relayburn-sdk/src/query_verbs/tests.rs
  • packages/mcp/CHANGELOG.md
  • packages/relayburn/CHANGELOG.md
  • packages/sdk-node/CHANGELOG.md
📝 Walkthrough

Walkthrough

The SDK now detects unknown model pricing, creates token-ranked unpriced findings, and exposes pricing status. Hotspot queries and CLI rendering support the new finding kind. Pricing flattening preserves primary-provider entries. Node types and changelogs document the output.

Changes

Unpriced hotspot reporting

Layer / File(s) Summary
Primary-provider pricing precedence
crates/relayburn-sdk/src/analyze/pricing.rs
The pricing flattener preserves Anthropic and OpenAI entries over later reseller entries. Tests cover current-generation models and provider precedence.
Finding status and token aggregation
crates/relayburn-sdk/src/analyze/findings.rs, crates/relayburn-sdk/src/analyze/*.rs, crates/relayburn-sdk/src/lib.rs, crates/relayburn-sdk/src/query_verbs/mod.rs
Findings now carry pricing status. Unknown-price turns aggregate by session and token volume. Unpriced findings sort before priced findings. Other finding constructors initialize the new field.
Hotspot selection and rendering
crates/relayburn-sdk/src/query_verbs/hotspots.rs, crates/relayburn-cli/src/commands/hotspots/*, crates/relayburn-sdk/src/query_verbs/tests.rs
Hotspot queries accept and generate unpriced-usage findings. CLI output displays unpriced. End-to-end tests validate metadata, token savings, and JSON serialization.
Public output and release documentation
packages/sdk-node/src/index.d.ts, CHANGELOG.md, packages/*/CHANGELOG.md
Node types expose token estimates and pricingStatus. Changelogs describe unknown pricing detection and token-volume ranking.

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

Sequence Diagram(s)

sequenceDiagram
  participant HotspotsQuery
  participant FindingAnalyzer
  participant HotspotRenderer
  HotspotsQuery->>FindingAnalyzer: request unpriced-usage findings
  FindingAnalyzer->>FindingAnalyzer: aggregate unknown-price turns by session and tokens
  FindingAnalyzer->>HotspotsQuery: return token-ranked findings
  HotspotsQuery->>HotspotRenderer: pass pricing status and savings
  HotspotRenderer->>HotspotRenderer: render unpriced label
Loading

Possibly related PRs

Poem

A rabbit reviews the tokens in flight,
Unknown prices now show in sight.
Priced finds keep their dollar glow,
Unpriced sessions rank by flow.
The hotspot trail is clear and bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements token-ranked unpriced findings, but the provided changeset does not show the required five pricing entries from issue #503. Add or clearly include pricing entries for all five models: claude-opus-5, claude-sonnet-5, gpt-5.6-sol, gpt-5.6-luna, and gpt-5.6-terra.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes support issue #503 through pricing precedence, unpriced finding handling, API exposure, rendering, tests, and changelog updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly summarizes the pricing coverage and unpriced hotspot ranking changes.
Description check ✅ Passed The description directly explains the pricing updates, unpriced finding behavior, ranking changes, API updates, and test coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-503-unpriced-models

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

const PRIMARY_PRICING_PROVIDERS: &[&str] = &["anthropic", "openai"];

P1 Badge Preserve Google’s first-party tariffs too

When the refreshed snapshot contains a Google model under both google and later reseller providers, this allow-list still leaves the reseller as the winner. For example, gemini-3.1-flash-image-preview now resolves to Abacus's $3/Mtok output rate instead of Google's $60/Mtok rate, while gemini-2.5-pro resolves to Cortecs instead of Google, substantially corrupting costs for Gemini sessions. Include the applicable Google first-party provider IDs in the precedence rule or derive ownership without a two-vendor allow-list.


https://github.com/AgentWorkforce/burn/blob/7dd61144c652dd95f8f6c1d8702cff6a6b3d028a/crates/relayburn-sdk/data/models.dev.json#L1
P1 Badge Honor the new context-tier tariffs

For turns beyond the context threshold, the newly vendored gpt-5.6-sol, gpt-5.6-luna, and gpt-5.6-terra records specify higher tiers/context_over_200k rates, but ModelsDevCost and flatten discard those fields and always use the base tariff. A gpt-5.6-sol turn over 272K context is therefore billed at $5/$30 per Mtok rather than the snapshot's $10/$45 tier, so the advertised pricing coverage underreports precisely the long-context sessions most likely to dominate hotspot costs.


pricing_status: FindingPricingStatus::Priced,

P2 Badge Propagate unpriced status into detector findings

When an unknown-model turn also forms a retry, failure, edit, or skill finding, the detector cost path uses sum_turn_costs, which explicitly converts unpriced turns to $0, and this constructor then unconditionally marks that result as Priced. The same response consequently contains the new unpriced-usage warning alongside a pattern finding rendered as $0.00 (or a partially priced amount for mixed-model findings), still presenting an unknown saving as a real USD estimate and misranking it among priced findings. The contributing turns' pricing coverage needs to flow into these findings rather than defaulting every detector result to Priced.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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 (2)
crates/relayburn-sdk/src/analyze/pricing.rs (1)

302-322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a reverse-order case to the primary-precedence test.

This test only covers the case where openai appears before reseller in the source JSON. The flatten implementation also correctly protects primary pricing when the reseller entry appears first in file order (the reseller entry gets overwritten later when the primary provider is processed). Add a second test case with reseller listed before openai to lock in that direction too, since models.dev.json provider ordering is not guaranteed and the code comment at Line 87 explicitly notes "their order is not a pricing-precedence contract."

🧪 Suggested additional test
+    #[test]
+    fn flatten_prefers_primary_vendor_when_reseller_listed_first() {
+        let raw = r#"{
+            "reseller": {
+                "models": {
+                    "gpt-example": { "cost": { "input": 1.5, "output": 12, "reasoning": 12 } }
+                }
+            },
+            "openai": {
+                "models": {
+                    "gpt-example": { "cost": { "input": 5, "output": 30 } }
+                }
+            }
+        }"#;
+        let table = parse_pricing(raw).unwrap();
+        let cost = table.get("gpt-example").unwrap();
+        assert_eq!(cost.input, 5.0);
+        assert_eq!(cost.output, 30.0);
+        assert_eq!(cost.reasoning_mode, ReasoningMode::SameAsOutput);
+    }
🤖 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 `@crates/relayburn-sdk/src/analyze/pricing.rs` around lines 302 - 322, Add a
reverse-order case alongside
flatten_prefers_primary_vendor_over_later_reseller_copy, placing the reseller
provider before openai in the raw JSON while keeping the duplicate model and
expected primary pricing assertions. Verify input, output, and reasoning_mode
still come from the openai entry.
crates/relayburn-sdk/src/query_verbs/tests.rs (1)

1056-1112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the ranking path in this test.

This query requests only unpriced-usage and creates one unpriced session. The assertions verify metadata and serialization, but they cannot detect token-order regressions or verify that unpriced findings precede priced findings. Add a second unpriced session with a smaller token total and include a priced finding in the sorted result set. Assert the expected order.

🤖 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 `@crates/relayburn-sdk/src/query_verbs/tests.rs` around lines 1056 - 1112, The
test hotspots_findings_surface_unpriced_usage_with_token_rank currently
exercises only one unpriced finding, so it cannot validate ranking. Add a second
unpriced session with a lower total token count and ensure the fixture also
produces a priced finding by broadening the query beyond only unpriced-usage;
then assert the sorted findings order, with the higher-token unpriced finding
first and unpriced findings preceding the priced finding, while retaining the
existing metadata and serialization checks.
🤖 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 `@crates/relayburn-sdk/src/analyze/pricing.rs`:
- Around line 302-322: Add a reverse-order case alongside
flatten_prefers_primary_vendor_over_later_reseller_copy, placing the reseller
provider before openai in the raw JSON while keeping the duplicate model and
expected primary pricing assertions. Verify input, output, and reasoning_mode
still come from the openai entry.

In `@crates/relayburn-sdk/src/query_verbs/tests.rs`:
- Around line 1056-1112: The test
hotspots_findings_surface_unpriced_usage_with_token_rank currently exercises
only one unpriced finding, so it cannot validate ranking. Add a second unpriced
session with a lower total token count and ensure the fixture also produces a
priced finding by broadening the query beyond only unpriced-usage; then assert
the sorted findings order, with the higher-token unpriced finding first and
unpriced findings preceding the priced finding, while retaining the existing
metadata and serialization checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d6cd03e7-50f6-4a16-9165-995f3b3330e7

📥 Commits

Reviewing files that changed from the base of the PR and between 962b2b7 and 7dd6114.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • crates/relayburn-cli/src/commands/hotspots/human.rs
  • crates/relayburn-cli/src/commands/hotspots/mod.rs
  • crates/relayburn-sdk/data/models.dev.json
  • crates/relayburn-sdk/src/analyze.rs
  • crates/relayburn-sdk/src/analyze/findings.rs
  • crates/relayburn-sdk/src/analyze/ghost_surface.rs
  • crates/relayburn-sdk/src/analyze/pricing.rs
  • crates/relayburn-sdk/src/analyze/tool_output_bloat.rs
  • crates/relayburn-sdk/src/lib.rs
  • crates/relayburn-sdk/src/query_verbs/hotspots.rs
  • crates/relayburn-sdk/src/query_verbs/mod.rs
  • crates/relayburn-sdk/src/query_verbs/tests.rs
  • packages/mcp/CHANGELOG.md
  • packages/relayburn/CHANGELOG.md
  • packages/sdk-node/CHANGELOG.md
  • packages/sdk-node/src/index.d.ts

@devin-ai-integration devin-ai-integration 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.

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread packages/mcp/CHANGELOG.md Outdated
Comment thread CHANGELOG.md

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

All reported issues were addressed across 17 files

Not reviewed (too large): crates/relayburn-sdk/data/models.dev.json (~2 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/relayburn-sdk/src/analyze/ghost_surface.rs
Comment thread crates/relayburn-sdk/src/analyze/tool_output_bloat.rs
Comment thread CHANGELOG.md
Comment thread crates/relayburn-sdk/src/query_verbs/tests.rs
Comment thread crates/relayburn-sdk/src/analyze/findings.rs Outdated
Comment thread packages/mcp/CHANGELOG.md Outdated
@willwashburn

Copy link
Copy Markdown
Member Author

Validated all three Codex findings and fixed them in aa0ad71:

  • First-party precedence now includes Google, Google Vertex, and xAI in addition to Anthropic/OpenAI, with a Google-vs-reseller regression test.
  • models.dev context tiers are retained and cost calculation selects the highest applicable tier from total input context; hotspot attribution uses the same effective rate. A GPT-5.6 Sol boundary test confirms base pricing at 272K and $10/$45 tier pricing above it.
  • Detector findings in sessions containing unknown-price turns now clear partial/zero USD estimates, carry pricingStatus=unpriced, and rank by the session unpriced-token volume. A regression test covers the false-$0 detector case.

cargo fmt --all -- --check and cargo test --workspace --quiet both pass (838 passed, 5 ignored in the SDK suite).

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

All reported issues were addressed across 16 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/relayburn-sdk/src/analyze/cost.rs
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.

Pricing table missing current-generation models — unpriced turns bury real hotspots

1 participant