Skip to content

Commit ef81c57

Browse files
committed
fix(web): fallback leaves a custom model's exact slug unexpanded
1 parent dca7dde commit ef81c57

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,17 +1200,19 @@ function withFallbackInstanceOptions(input: {
12001200
return modelOptions;
12011201
}
12021202
const requestedOptions = modelOptions[requestedInstanceId];
1203-
const requestedDriver = input.providers.find(
1203+
const requestedProvider = input.providers.find(
12041204
(provider) => provider.instanceId === requestedInstanceId,
1205-
)?.driver;
1205+
);
12061206
// The model of the selection the options came from, which can differ from the shown model's source.
1207-
// It can be a driver alias such as "5.4" for "gpt-5.4". Catalog aliases are not used: Antigravity's
1208-
// "antigravity-default" names a different model on each instance.
1207+
// It can be a driver alias such as "5.4" for "gpt-5.4", expanded only when the requested instance
1208+
// does not offer that exact slug (a custom model can be named "5.4"). Catalog aliases are not used:
1209+
// Antigravity's "antigravity-default" names a different model on each instance.
12091210
const requestedModel = input.optionSelections?.[requestedInstanceId]?.model;
12101211
const sameModel =
12111212
requestedModel === input.selectedModel ||
1212-
normalizeModelSlug(requestedModel, input.selectedProvider) === input.selectedModel;
1213-
if (!requestedOptions || requestedDriver !== input.selectedProvider || !sameModel) {
1213+
(!requestedProvider?.models.some((model) => model.slug === requestedModel) &&
1214+
normalizeModelSlug(requestedModel, input.selectedProvider) === input.selectedModel);
1215+
if (!requestedOptions || requestedProvider?.driver !== input.selectedProvider || !sameModel) {
12141216
return modelOptions;
12151217
}
12161218
return { ...modelOptions, [selectedInstanceId]: requestedOptions };

‎apps/web/src/modelSelection.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,30 @@ describe("composer fallback to another instance of the same driver", () => {
969969
expect(traits.promptEffort).toBe("xhigh");
970970
});
971971

972+
it("does not alias-expand a custom model the requested instance offers", () => {
973+
// A disabled Codex instance reports only its custom models; this one is named "5.4".
974+
const disabledCodex = ProviderInstanceId.make("codex");
975+
const { state, traits } = composerFor({
976+
providers: [
977+
{
978+
...provider({ provider: codex, instanceId: disabledCodex }),
979+
enabled: false,
980+
models: [reasoningModel("5.4", "reasoningEffort", { isCustom: true })],
981+
},
982+
{
983+
...provider({ provider: codex, instanceId: "codex_team" }),
984+
models: [reasoningModel("gpt-5.4", "reasoningEffort")],
985+
},
986+
],
987+
threadModelSelection: createModelSelection(disabledCodex, "5.4", [
988+
{ id: "reasoningEffort", value: "xhigh" },
989+
]),
990+
});
991+
992+
expect(state.selectedModel).toBe("gpt-5.4");
993+
expect(traits.modelOptionsForDispatch).toBeUndefined();
994+
});
995+
972996
it("does not carry options through an alias that names another model per instance", () => {
973997
// "antigravity-default" is each Antigravity instance's current model.
974998
const antigravity = ProviderDriverKind.make("antigravity");

0 commit comments

Comments
 (0)