fix: match model filter on canonical_model_name and restore routing info for cost recalc - #5029
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughLog storage now indexes canonical model names, log filtering matches either wire model or canonical model name, and cost recalculation now rebuilds routing info from stored canonical model data. ChangesCanonical Model Name Handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
e466e95 to
a2be949
Compare
d7cd79a to
4077e3a
Compare
4077e3a to
8429b4f
Compare
a2be949 to
d19f0cc
Compare
d19f0cc to
d8627f7
Compare
8429b4f to
7d2975f
Compare
d8627f7 to
964cf81
Compare
7d2975f to
5babf22
Compare
becea36 to
0475258
Compare
5babf22 to
a9c404a
Compare
0475258 to
fab2b0f
Compare
a9c404a to
53af499
Compare
fab2b0f to
a09364b
Compare
6247490 to
98e1996
Compare
a09364b to
62560d6
Compare
98e1996 to
3a04068
Compare
9491a4b to
ca6e660
Compare
3a04068 to
439b154
Compare
Merge activity
|
The base branch was changed.
ca6e660 to
838e2d5
Compare
…nfo for cost recalc (#5029) ## Summary Model filtering in the log store only matched against the wire model column, so filtering by a canonical model name (e.g. `gpt-4o-mini`) would miss requests routed through an alias whose wire model differed. Similarly, cost recalculation for stored logs dropped the canonical model name, causing pricing lookups to fail and return null costs for those entries. ## Changes - Updated `applyFilters` in `rdb.go` to match against both `model` and `canonical_model_name` when filtering by model, so alias-routed requests surface correctly under their canonical name. - In `calculateCostForLog`, the `RoutingInfo` field is now populated with provider and model from the log entry. When a `canonical_model_name` is present, a `ResolvedKeyAlias` is reconstructed so that cost recalculation has the same routing context that live logging used, preventing null costs. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [x] Plugins - [ ] UI (React) - [ ] Docs ## How to test 1. Create a key alias that maps to a model with a different wire model name (e.g. an alias for `gpt-4o-mini` that routes to a provider-specific wire model). 2. Send a request through that alias and confirm the log entry is stored with both `model` and `canonical_model_name` populated. 3. Filter logs by the canonical model name and verify the aliased request appears in results. 4. Trigger a cost recalculation for that log entry and confirm a non-null cost is returned. ```sh go test ./framework/logstore/... go test ./plugins/logging/... ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No security implications. Changes are scoped to log filtering and cost recalculation logic. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
…nfo for cost recalc (maximhq#5029) ## Summary Model filtering in the log store only matched against the wire model column, so filtering by a canonical model name (e.g. `gpt-4o-mini`) would miss requests routed through an alias whose wire model differed. Similarly, cost recalculation for stored logs dropped the canonical model name, causing pricing lookups to fail and return null costs for those entries. ## Changes - Updated `applyFilters` in `rdb.go` to match against both `model` and `canonical_model_name` when filtering by model, so alias-routed requests surface correctly under their canonical name. - In `calculateCostForLog`, the `RoutingInfo` field is now populated with provider and model from the log entry. When a `canonical_model_name` is present, a `ResolvedKeyAlias` is reconstructed so that cost recalculation has the same routing context that live logging used, preventing null costs. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [x] Plugins - [ ] UI (React) - [ ] Docs ## How to test 1. Create a key alias that maps to a model with a different wire model name (e.g. an alias for `gpt-4o-mini` that routes to a provider-specific wire model). 2. Send a request through that alias and confirm the log entry is stored with both `model` and `canonical_model_name` populated. 3. Filter logs by the canonical model name and verify the aliased request appears in results. 4. Trigger a cost recalculation for that log entry and confirm a non-null cost is returned. ```sh go test ./framework/logstore/... go test ./plugins/logging/... ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No security implications. Changes are scoped to log filtering and cost recalculation logic. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Model filtering in the log store only matched against the wire model column, so filtering by a canonical model name (e.g.
gpt-4o-mini) would miss requests routed through an alias whose wire model differed. Similarly, cost recalculation for stored logs dropped the canonical model name, causing pricing lookups to fail and return null costs for those entries.Changes
applyFiltersinrdb.goto match against bothmodelandcanonical_model_namewhen filtering by model, so alias-routed requests surface correctly under their canonical name.calculateCostForLog, theRoutingInfofield is now populated with provider and model from the log entry. When acanonical_model_nameis present, aResolvedKeyAliasis reconstructed so that cost recalculation has the same routing context that live logging used, preventing null costs.Type of change
Affected areas
How to test
gpt-4o-minithat routes to a provider-specific wire model).modelandcanonical_model_namepopulated.Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
No security implications. Changes are scoped to log filtering and cost recalculation logic.
Checklist
docs/contributing/README.mdand followed the guidelines