Skip to content

Commit b21fad2

Browse files
committed
fix(models): preserve stripped profile aliases
1 parent 6f45fdf commit b21fad2

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

src/agents/model-selection-shared.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,16 @@ export function resolveConfiguredModelRef(
723723
const manifestPluginContext = createModelManifestPluginContext(params);
724724
const profileStripped = Boolean(modelWithoutProfile && modelWithoutProfile !== trimmed);
725725
const exactAliasCandidate = findModelAliasCandidate(params.cfg, trimmed);
726-
if (profileStripped && exactAliasCandidate) {
726+
const strippedAliasCandidate = profileStripped
727+
? findModelAliasCandidate(params.cfg, modelWithoutProfile)
728+
: undefined;
729+
const profileAliasCandidate = profileStripped
730+
? (exactAliasCandidate ?? strippedAliasCandidate)
731+
: undefined;
732+
if (profileAliasCandidate) {
727733
const aliasRef = parseModelRefWithCompatAlias({
728734
cfg: params.cfg,
729-
raw: exactAliasCandidate.keyRaw,
735+
raw: profileAliasCandidate.keyRaw,
730736
defaultProvider: params.defaultProvider,
731737
allowManifestNormalization: params.allowManifestNormalization,
732738
allowPluginNormalization: params.allowPluginNormalization,
@@ -747,10 +753,7 @@ export function resolveConfiguredModelRef(
747753
manifestPlugins: manifestPluginContext.get(),
748754
});
749755
}
750-
const strippedAliasCandidate = profileStripped
751-
? findModelAliasCandidate(params.cfg, modelWithoutProfile)
752-
: undefined;
753-
const aliasCandidate = exactAliasCandidate ?? strippedAliasCandidate;
756+
const aliasCandidate = profileStripped ? undefined : exactAliasCandidate;
754757
const manifestPlugins = manifestPluginContext.peek();
755758
if (
756759
aliasCandidate &&

src/agents/model-selection.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,41 @@ describe("model-selection", () => {
20712071
expect(result).toEqual({ provider: "openai", model: "gpt-5.5" });
20722072
});
20732073

2074+
it("prefers stripped auth-profile aliases before configured-provider stripping", () => {
2075+
const cfg = {
2076+
agents: {
2077+
defaults: {
2078+
model: { primary: "nemotron-bolt/nemotron-3-super-120b@prod" },
2079+
models: {
2080+
"openai/nemotron-bolt/nemotron-3-super-120b": {
2081+
alias: "nemotron-bolt/nemotron-3-super-120b",
2082+
},
2083+
},
2084+
},
2085+
},
2086+
models: {
2087+
providers: {
2088+
"nemotron-bolt": {
2089+
api: "openai-completions",
2090+
baseUrl: "http://127.0.0.1:8080/v1",
2091+
models: [{ id: "nemotron-3-super-120b", name: "Nemotron" }],
2092+
},
2093+
},
2094+
},
2095+
} as unknown as OpenClawConfig;
2096+
2097+
const result = resolveConfiguredModelRef({
2098+
cfg,
2099+
defaultProvider: "anthropic",
2100+
defaultModel: "claude-sonnet-4-6",
2101+
});
2102+
2103+
expect(result).toEqual({
2104+
provider: "openai",
2105+
model: "nemotron-bolt/nemotron-3-super-120b",
2106+
});
2107+
});
2108+
20742109
it("resolves provider-qualified defaults without normalizing every aliasless configured model", () => {
20752110
providerModelNormalizationMock.normalizeProviderModelIdWithRuntime.mockClear();
20762111
const models = Object.fromEntries(

0 commit comments

Comments
 (0)