Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: stop truncating the Basic LLM provider list at 100 entries (#16453)

Joe Castle500b4c533e93
diff --git a/__tests__/hooks/query/use-search-providers.test.tsx b/__tests__/hooks/query/use-search-providers.test.tsx
new file mode 100644
index 0000000000..3d0868694a
--- /dev/null
+++ b/__tests__/hooks/query/use-search-providers.test.tsx
@@ -0,0 +1,45 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { renderHook, waitFor } from "@testing-library/react";
+import { http, HttpResponse } from "msw";
+import React from "react";
+import { describe, expect, it } from "vitest";
+import { useSearchProviders } from "#/hooks/query/use-search-providers";
+import { server } from "#/mocks/node";
+
+const wrapper = ({ children }: { children: React.ReactNode }) => {
+ const client = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
+};
+
+describe("useSearchProviders", () => {
+ it("returns providers that sort past the first 100 entries", async () => {
+ // Arrange: mirror the real local agent-server, whose litellm-derived
+ // provider list is ~150 entries long and sorted alphabetically, putting
+ // "openrouter" at index 101, past any 100-item cap.
+ const providers = [
+ ...Array.from(
+ { length: 101 },
+ (_, i) => `provider_${String(i).padStart(3, "0")}`,
+ ),
+ "openrouter",
+ ...Array.from({ length: 47 }, (_, i) => `zprovider_${i}`),
+ ];
+ server.use(
+ http.get("/api/llm/providers", () => HttpResponse.json({ providers })),
+ http.get("/api/llm/models/verified", () =>
+ HttpResponse.json({ models: { openhands: ["claude-opus-4-7"] } }),
+ ),
+ );
+
+ // Act
+ const { result } = renderHook(() => useSearchProviders(), { wrapper });
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+
+ // Assert: the picker must surface every provider the backend reports.
+ const names = result.current.data?.map((provider) => provider.name) ?? [];
+ expect(names).toContain("openrouter");
+ expect(names).toHaveLength(providers.length + 1); // + the verified "openhands"
+ });
+});
diff --git a/src/hooks/query/use-search-providers.ts b/src/hooks/query/use-search-providers.ts
index 2bf93970a3..8fd4c90cf5 100644
--- a/src/hooks/query/use-search-providers.ts
+++ b/src/hooks/query/use-search-providers.ts
@@ -17,11 +17,10 @@ export const useSearchProviders = () =>
queryFn: fetchVerifiedModelsByProvider,
staleTime: VERIFIED_MODELS_STALE_TIME,
});
- // Providers are a small set; fetch all in one call with a high limit.
- const page = await ConfigService.searchProviders(
- { limit: 100 },
- verifiedByProvider,
- );
+ // Fetch every provider in one call. Passing no limit is deliberate:
+ // litellm exposes ~150 providers, so any fixed cap silently truncates
+ // the picker: `openrouter` sorts past position 100 and disappears.
+ const page = await ConfigService.searchProviders({}, verifiedByProvider);
return page.items;
},
staleTime: VERIFIED_MODELS_STALE_TIME,