mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-20 05:56:56 +00:00
fix(provider): list models in one page for Anthropic and Gemini
Model discovery used each API's default page size: 20 for Anthropic and 50 for Gemini. A full catalog needed several sequential requests, and at pod start that overran the 5s warm-fill budget. One replica then logged "initial discovery ... context deadline exceeded" and went without that provider's models until the next probe. Every page now asks for the documented maximum of 1000: Anthropic limit and Gemini pageSize. Gemini gets pageSize on each page, because it requires the same parameters across one listing. Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
@@ -471,9 +471,10 @@ func TestAnthropicAdapter_ListModels(t *testing.T) {
|
||||
// page via ?after_id=<last_id> and return the union of both pages, not
|
||||
// just the first page's 20 (Anthropic's own default page size).
|
||||
func TestAnthropicAdapter_ListModels_FollowsPagination(t *testing.T) {
|
||||
var gotAfterIDs []string
|
||||
var gotAfterIDs, gotLimits []string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotAfterIDs = append(gotAfterIDs, r.URL.Query().Get("after_id"))
|
||||
gotLimits = append(gotLimits, r.URL.Query().Get("limit"))
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if r.URL.Query().Get("after_id") == "" {
|
||||
_, _ = w.Write([]byte(`{"data":[{"id":"claude-opus-5"},{"id":"claude-sonnet-5"}],"has_more":true,"last_id":"claude-sonnet-5"}`))
|
||||
@@ -504,6 +505,13 @@ func TestAnthropicAdapter_ListModels_FollowsPagination(t *testing.T) {
|
||||
if len(gotAfterIDs) != 2 || gotAfterIDs[0] != "" || gotAfterIDs[1] != "claude-sonnet-5" {
|
||||
t.Errorf("after_id sequence = %#v, want [\"\", \"claude-sonnet-5\"] (first page unqualified, second page's after_id = first page's last_id)", gotAfterIDs)
|
||||
}
|
||||
// Every page asks for Anthropic's maximum page size, so a real catalog
|
||||
// arrives in one request inside warmFillTimeout.
|
||||
for i, l := range gotLimits {
|
||||
if l != "1000" {
|
||||
t.Errorf("page %d limit = %q, want \"1000\"", i, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicAdapter_ListModels_PageCapStopsRunawayPagination proves
|
||||
|
||||
Reference in New Issue
Block a user