Skip to content

Commit 39543a3

Browse files
committed
fix: separate static and live catalog flights
1 parent 59d95c0 commit 39543a3

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/codex/catalog/provider-fetch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ function stableJson(value: unknown): string {
8282
function providerCatalogFingerprint(name: string, prov: OcxProviderConfig): Record<string, unknown> {
8383
return {
8484
n: name,
85-
live: prov.liveModels !== false,
85+
// Preserve the persisted tri-state. Registry enrichment may turn an omitted value into
86+
// `false` while an explicit `true` stays live, so those callers must not share a flight.
87+
live: prov.liveModels ?? null,
8688
base: prov.baseUrl ?? "",
8789
adapter: prov.adapter ?? "",
8890
models: [...(prov.models ?? [])].sort(),

tests/gather-routed-models-single-flight.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,40 @@ describe("gatherRoutedModels single-flight", () => {
163163
expect(a2).toEqual(a1);
164164
});
165165

166+
test("an omitted registry-static setting never shares a flight with explicit live discovery", async () => {
167+
let fetchCount = 0;
168+
globalThis.fetch = (async () => {
169+
fetchCount += 1;
170+
return new Response(JSON.stringify({ data: [{ id: "live-only" }] }), {
171+
status: 200,
172+
headers: { "content-type": "application/json" },
173+
});
174+
}) as typeof fetch;
175+
176+
const config = (liveModels?: true): OcxConfig => ({
177+
port: 10100,
178+
defaultProvider: "alibaba-token-plan",
179+
providers: {
180+
"alibaba-token-plan": {
181+
adapter: "openai-chat",
182+
baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
183+
apiKey: "test-key",
184+
models: ["configured-static"],
185+
...(liveModels === undefined ? {} : { liveModels }),
186+
},
187+
},
188+
});
189+
190+
const [registryStatic, explicitLive] = await Promise.all([
191+
gatherRoutedModels(config()),
192+
gatherRoutedModels(config(true)),
193+
]);
194+
195+
expect(fetchCount).toBe(1);
196+
expect(registryStatic.map(model => model.id)).toEqual(["configured-static"]);
197+
expect(explicitLive.map(model => model.id)).toEqual(["live-only"]);
198+
});
199+
166200
test("concurrent distinct keys keep flight-local combo omissions", async () => {
167201
globalThis.fetch = (async () =>
168202
new Response(JSON.stringify({ data: [{ id: "m1" }] }), {

0 commit comments

Comments
 (0)