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:
byungsker
2026-02-25 14:36:27 +09:00
committed by GitHub
parent 8f5f599a34
commit 177386ed73
12 changed files with 559 additions and 13 deletions

View File

@@ -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> = {