Skip to content

Commit 0313bb8

Browse files
committed
fix(zoo-gateway): negative-cache empty catalog misses too
An empty getModels() result still records a missing-id attempt; the retry guard no longer requires a non-empty models map.
1 parent 82a00f7 commit 0313bb8

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎src/api/providers/__tests__/zoo-gateway.spec.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,24 @@ describe("ZooGatewayHandler", () => {
819819
expect(handler.getModel().info.inputPrice).toBe(0)
820820
})
821821

822+
it("negative-caches an empty catalog response for a missing model", async () => {
823+
const { getModels } = await import("../fetchers/modelCache")
824+
vitest.mocked(getModels).mockResolvedValue({})
825+
826+
const handler = new ZooGatewayHandler({
827+
...mockOptions,
828+
zooGatewayModelId: "alibaba/qwen3.8-max",
829+
})
830+
831+
await handler.ensureModelFetched()
832+
vitest.mocked(getModels).mockClear()
833+
834+
await handler.ensureModelFetched()
835+
836+
expect(getModels).not.toHaveBeenCalled()
837+
expect(handler.getModel().info.inputPrice).toBe(0)
838+
})
839+
822840
it("deduplicates concurrent calls into a single fetch", async () => {
823841
const handler = new ZooGatewayHandler(mockOptions)
824842
const { getModels } = await import("../fetchers/modelCache")

‎src/api/providers/router-provider.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ export abstract class RouterProvider extends BaseProvider {
6868
const lastMissingAttempt = this.missingModelRefreshAt.get(id)
6969
if (
7070
lastMissingAttempt !== undefined &&
71-
Date.now() - lastMissingAttempt < RouterProvider.MISSING_MODEL_RETRY_MS &&
72-
Object.keys(this.models).length > 0
71+
Date.now() - lastMissingAttempt < RouterProvider.MISSING_MODEL_RETRY_MS
7372
) {
7473
return this.getModel()
7574
}

0 commit comments

Comments
 (0)