fix(provider): make small model fallback optional (#27405)

This commit is contained in:
Kit Langton
2026-05-13 20:44:34 -04:00
committed by GitHub
parent 5e41dbbcbf
commit 9818c9e8d0
2 changed files with 28 additions and 5 deletions

View File

@@ -1025,6 +1025,27 @@ test("getSmallModel respects config small_model override", async () => {
})
})
test("getSmallModel ignores invalid config small_model", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
await Bun.write(
path.join(dir, "opencode.json"),
JSON.stringify({
$schema: "https://opencode.ai/config.json",
small_model: "anthropic/not-a-real-model",
}),
)
},
})
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
set("ANTHROPIC_API_KEY", "test-api-key")
expect(await getSmallModel(ProviderID.anthropic)).toBeUndefined()
},
})
})
test("provider.sort prioritizes preferred models", () => {
const models = [
{ id: "random-model", name: "Random" },