mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 15:23:43 +00:00
fix(tui): resolve wrong provider prefix when session has model without modelProvider (#25874)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: f0953a7284
Co-authored-by: lbo728 <72309817+lbo728@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -3,6 +3,7 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resetLogger, setLoggerOverride } from "../logging/logger.js";
|
||||
import {
|
||||
buildAllowedModelSet,
|
||||
inferUniqueProviderFromConfiguredModels,
|
||||
parseModelRef,
|
||||
buildModelAliasIndex,
|
||||
modelKey,
|
||||
@@ -134,6 +135,85 @@ describe("model-selection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("inferUniqueProviderFromConfiguredModels", () => {
|
||||
it("infers provider when configured model match is unique", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"anthropic/claude-sonnet-4-6": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(
|
||||
inferUniqueProviderFromConfiguredModels({
|
||||
cfg,
|
||||
model: "claude-sonnet-4-6",
|
||||
}),
|
||||
).toBe("anthropic");
|
||||
});
|
||||
|
||||
it("returns undefined when configured matches are ambiguous", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"anthropic/claude-sonnet-4-6": {},
|
||||
"minimax/claude-sonnet-4-6": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(
|
||||
inferUniqueProviderFromConfiguredModels({
|
||||
cfg,
|
||||
model: "claude-sonnet-4-6",
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined for provider-prefixed model ids", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"anthropic/claude-sonnet-4-6": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(
|
||||
inferUniqueProviderFromConfiguredModels({
|
||||
cfg,
|
||||
model: "anthropic/claude-sonnet-4-6",
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("infers provider for slash-containing model id when allowlist match is unique", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"vercel-ai-gateway/anthropic/claude-sonnet-4-6": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(
|
||||
inferUniqueProviderFromConfiguredModels({
|
||||
cfg,
|
||||
model: "anthropic/claude-sonnet-4-6",
|
||||
}),
|
||||
).toBe("vercel-ai-gateway");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildModelAliasIndex", () => {
|
||||
it("should build alias index from config", () => {
|
||||
const cfg: Partial<OpenClawConfig> = {
|
||||
|
||||
Reference in New Issue
Block a user