add deprecated model fallback chain resolution

models can now be marked `deprecated: true` with a `fallback` slug
pointing to a replacement. `resolveCliModel` follows the chain
recursively (with cycle detection) until it finds a non-deprecated
model. this keeps deprecated models in the registry for backward
compatibility instead of removing them.

marks opencode/mimo-v2-pro-free as deprecated with fallback to
opencode/nemotron-3-super-free.

Made-with: Cursor
This commit is contained in:
Colin McDonnell
2026-04-03 18:45:47 +00:00
committed by pullfrog[bot]
parent a45c164b18
commit b8c4d5b716
6 changed files with 87 additions and 26 deletions
+26 -5
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { type ModelProvider, modelAliases, providers } from "../models.ts";
import { type ModelProvider, modelAliases, providers, resolveCliModel } from "../models.ts";
type ModelsDevModel = {
name: string;
@@ -38,10 +38,31 @@ describe("models.dev validity", async () => {
).toBeDefined();
});
it(`${alias.resolve} is not deprecated`, () => {
const model = data[parsed.provider]?.models[parsed.modelId];
if (!model) return; // covered by existence test above
expect(model.status, `${alias.resolve} is deprecated on models.dev`).not.toBe("deprecated");
if (!alias.deprecated) {
it(`${alias.resolve} is not deprecated`, () => {
const model = data[parsed.provider]?.models[parsed.modelId];
if (!model) return; // covered by existence test above
expect(model.status, `${alias.resolve} is deprecated on models.dev`).not.toBe("deprecated");
});
}
}
// deprecated models must have a fallback that resolves to a non-deprecated model
const deprecatedAliases = modelAliases.filter((a) => a.deprecated);
for (const alias of deprecatedAliases) {
it(`${alias.slug} (deprecated) has a fallback`, () => {
expect(
alias.fallback,
`deprecated model "${alias.slug}" is missing a fallback`
).toBeDefined();
});
it(`${alias.slug} (deprecated) fallback chain resolves`, () => {
const resolved = resolveCliModel(alias.slug);
expect(
resolved,
`fallback chain for "${alias.slug}" does not resolve to a non-deprecated model`
).toBeDefined();
});
}
});