feat: Fix model attribution for prefix-stripped token usage callbacks#1491
Conversation
… bare model name handling
…d related components
|
@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Description
provider,display_name,model_id, andmodel_ref.Composerand related components so selecting a model returns focus to the main composer input.Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR fixes a model attribution bug where LiteLLM strips provider prefixes (e.g.,
azure/gpt-5.2-chatbecomesgpt-5.2-chat) before invoking token tracking callbacks, causing incorrect model metadata to be displayed in the UI. The fix implements a dual-indexing system inTurnTokenAccumulatorthat reconciles both prefixed and bare model names with their metadata, preferring exact matches when available. Additionally, the PR improves UX by returning focus to the composer input after selecting a chat model and contains a minor metadata title change replacing en-dashes with hyphens.⏱️ Estimated Review Time: 15-30 minutes
💡 Review Order Suggestion
surfsense_backend/app/services/token_tracking_service.pysurfsense_backend/tests/unit/services/test_token_quota_service_cost.pysurfsense_web/components/new-chat/model-selector.tsxsurfsense_web/components/new-chat/chat-header.tsxsurfsense_web/components/assistant-ui/thread.tsxsurfsense_web/app/layout.tsxsurfsense_web/app/layout.tsx