Repository navigation
fix(router): SmartChatResponse.Model names the model that answered - #45
Merged
Merged
Conversation
When the gateway reroutes (free health breaker open, or a free-cascade fallback) Model reported the requested id. It is now the response body's model, else the X-Served-Model / X-Fallback-Model header, else the requested id. New SmartChatResponse.RequestedModel keeps the router's pick; existing fields are unchanged.
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.
Problem
The gateway sometimes serves a different model than the one requested:
In both cases
SmartChatResponse.Modelstill reported the id the router requested. Since #44 routes the free tiers to primaries whose breakers can be open, this is the common case on the free profile. Live example: requestingnvidia/nemotron-3.5-lightningwas answered bynvidia/nemotron-3-super-120b.What the gateway sends
Checked read-only in blockrun origin/main,
src/app/api/v1/chat/completions/route.ts:X-Health-Reroute: true,X-Original-Model, andX-Served-Model(route.ts:3421-3424).X-Original-ModelandX-Fallback-Model(route.ts:3441-3442, 3552, 3621, 3685, 4811).modelis the served model in both cases (confirmed live).Change
SmartChatResponse.Modelis now the model that answered. It is resolved in this order:modelX-Served-ModelheaderX-Fallback-ModelheaderSmartChatResponse.RequestedModel(json:"requested_model") holds the router's pick.Routing.Modelalready held it and is unchanged.ChatCompletionnow wraps a new unexportedchatCompletionHeaders, which uses the existingdoRequestHeaders, soSmartChatcan read the response headers. Its public behaviour is unchanged. When a response comes from the local cache, headers are nil and the body'smodelstill applies.Tests
router_served_model_test.gouses an httptest server to cover five cases:modeldiffers from the requestX-Served-Model)X-Fallback-Model)Each case also asserts
RequestedModelandRouting.Model. A separate test checks the JSON keys stay additive.Checks
go build ./...: okgo vet ./...: okgo test ./...: okBLOCKRUN_LIVE_CATALOG=1 go test -run TestRoutingTableMatchesLiveCatalog .: ok