fix(gateway): track uptime for used provider - #1507
Merged
Merged
Conversation
When low-uptime fallback routes a request to a different provider, ensure that the uptime stats are tracked for the actual provider that handled the request, not the originally requested one. The issue was that `baseModelName` was derived from `finalModelInfo` which is computed after fallback using the updated `usedModel`. If the search failed, it would fall back to using `usedModel` directly (a provider-specific name) instead of the canonical model ID. Now we use `modelInfo.id` (set before any routing/fallback) as the primary source for the canonical model ID, ensuring correct stats attribution. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
WalkthroughChanges the baseModelName selection logic in the chat handler to prefer the canonical model ID from modelInfo when available, with a fallback order of modelInfo.id, finalModelInfo?.id, then usedModel. Updates corresponding test data to ensure model/provider pairs align properly. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
steebchen
enabled auto-merge
January 27, 2026 02:19
steebchen
added this pull request to the merge queue
Jan 27, 2026
This was referenced Jan 27, 2026
steebchen
added a commit
that referenced
this pull request
Jan 29, 2026
## Summary - Fixes uptime tracking to use the actual provider that handled a request, not the originally requested one - When low-uptime fallback routes to a different provider, stats are now correctly attributed to the fallback provider - Fixes test data inconsistency where `usedModel` had wrong provider prefix ## Test plan - [x] Existing stats-calculator tests pass (17 tests) - [x] Provider-metrics tests pass (19 tests) - [x] Build succeeds - [ ] Verify uptime stats are correctly attributed after low-uptime fallback in production 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved model identifier resolution to ensure the correct model is used for statistics and logging when routing or fallback occurs. * **Tests** * Aligned test data to ensure model and provider pairs are correctly matched in statistics calculations. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Feb 11, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usedModelhad wrong provider prefixTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.