Config: expand Kilo catalog and persist selected Kilo models (#24921)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: f5a7e1a385
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Gustavo Madeira Santana
2026-02-23 21:17:37 -05:00
committed by GitHub
parent 6c441ea797
commit 5239b55c0a
14 changed files with 668 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ import type { OpenClawConfig } from "../config/config.js";
import {
applyModelAllowlist,
applyModelFallbacksFromSelection,
pruneKilocodeProviderModelsToAllowlist,
promptDefaultModel,
promptModelAllowlist,
} from "./model-picker.js";
@@ -60,6 +61,18 @@ function createSelectAllMultiselect() {
return vi.fn(async (params) => params.options.map((option: { value: string }) => option.value));
}
function makeProviderModel(id: string, name: string) {
return {
id,
name,
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 200000,
maxTokens: 8192,
};
}
describe("promptDefaultModel", () => {
it("supports configuring vLLM during onboarding", async () => {
loadModelCatalog.mockResolvedValue([
@@ -249,3 +262,60 @@ describe("applyModelFallbacksFromSelection", () => {
});
});
});
describe("pruneKilocodeProviderModelsToAllowlist", () => {
it("keeps only selected model definitions in provider configs", () => {
const config = {
models: {
providers: {
kilocode: {
baseUrl: "https://api.kilo.ai/api/gateway/",
api: "openai-completions",
models: [
makeProviderModel("anthropic/claude-opus-4.6", "Claude Opus 4.6"),
makeProviderModel("minimax/minimax-m2.5:free", "MiniMax M2.5 (Free)"),
],
},
},
},
} as OpenClawConfig;
const next = pruneKilocodeProviderModelsToAllowlist(config, [
"kilocode/anthropic/claude-opus-4.6",
]);
expect(next.models?.providers?.kilocode?.models?.map((model) => model.id)).toEqual([
"anthropic/claude-opus-4.6",
]);
});
it("does not modify non-kilo provider model catalogs", () => {
const config = {
models: {
providers: {
kilocode: {
baseUrl: "https://api.kilo.ai/api/gateway/",
api: "openai-completions",
models: [makeProviderModel("anthropic/claude-opus-4.6", "Claude Opus 4.6")],
},
minimax: {
baseUrl: "https://api.minimax.io/anthropic",
api: "anthropic-messages",
models: [makeProviderModel("MiniMax-M2.5", "MiniMax M2.5")],
},
},
},
} as OpenClawConfig;
const next = pruneKilocodeProviderModelsToAllowlist(config, [
"kilocode/anthropic/claude-opus-4.6",
]);
expect(next.models?.providers?.kilocode?.models?.map((model) => model.id)).toEqual([
"anthropic/claude-opus-4.6",
]);
expect(next.models?.providers?.minimax?.models?.map((model) => model.id)).toEqual([
"MiniMax-M2.5",
]);
});
});