Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix: ask Devin about swe-1.7 in Devin's own spelling
Jack Rudenkod408ac96ee56
diff --git a/packages/cli/src/providers/model-availability.test.ts b/packages/cli/src/providers/model-availability.test.tsindex 7374cbe5..b7f59fe1 100644--- a/packages/cli/src/providers/model-availability.test.ts+++ b/packages/cli/src/providers/model-availability.test.ts@@ -1,12 +1,23 @@import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";+import { readFileSync } from "node:fs";+import { join } from "node:path";import { catalogRouteForProvider } from "./catalog-route-bindings.js";import { credentials } from "../auth/credentials/authority.js";import type { SlimModelEntry } from "./all-models-cache.js";import { _resetCatalogClient, _setCatalogEntriesForTest } from "./catalog-client.js";+import { decodeModelConfigs } from "./devin/devin-models.js";import { providerServesModel } from "./model-availability.js";-import { invalidateModelDiscovery } from "./model-discovery.js";+import {+ type DiscoveredModel,+ getModelDiscoveryFetcher,+ invalidateModelDiscovery,+ registerModelDiscoveryFetcher,+} from "./model-discovery.js";+import "./model-discovery-builtins.js";+import { devinModelsCatalogEntry } from "./model-resolvers/devin.js";import type { ProviderDefinition } from "./provider-definitions.js";+import { route } from "./routing-rules.js";import { clearRuntimeRegistry, registerRuntimeProvider } from "./runtime-providers.js";const CATALOG_PROVIDER = "openrouter";@@ -15,6 +26,25 @@ const DISCOVERY_PROVIDER = "availability-discovery-test";const realFetch = globalThis.fetch;const realGetRequestAuth = credentials.getRequestAuth;+const realIsAvailable = credentials.isAvailable;+const realDescribeReadiness = credentials.describeReadiness;+const realDevinDiscovery = getModelDiscoveryFetcher("devin-connect");++if (!realDevinDiscovery) throw new Error("Devin discovery fetcher was not registered");++const DEVIN_BUG_UIDS = new Set(["swe-1-7", "swe-1-7-medium"]);+const devinFixturePath = join(+ import.meta.dir,+ "../test-fixtures/devin/GetCliModelConfigs.res.bin"+);+const devinModelsCatalog: DiscoveredModel[] = decodeModelConfigs(readFileSync(devinFixturePath))+ .filter((model) => DEVIN_BUG_UIDS.has(model.uid))+ .map(devinModelsCatalogEntry)+ .map(({ wireId, ...rest }) => ({ id: wireId, ...rest }));++if (devinModelsCatalog.length !== DEVIN_BUG_UIDS.size) {+ throw new Error("Captured Devin fixture is missing the SWE-1.7 regression uids");+}function catalogEntry(modelId: string,@@ -69,6 +99,10 @@ function stubModelsCatalog(...ids: string[]): void {) as unknown as typeof fetch;}+function stubDevinModelsCatalog(): void {+ registerModelDiscoveryFetcher("devin-connect", async () => devinModelsCatalog);+}+beforeEach(() => {_resetCatalogClient();// Keep every test off the real on-disk catalog, including discovery tests.@@ -90,6 +124,9 @@ afterEach(() => {invalidateModelDiscovery();clearRuntimeRegistry();credentials.getRequestAuth = realGetRequestAuth;+ credentials.isAvailable = realIsAvailable;+ credentials.describeReadiness = realDescribeReadiness;+ registerModelDiscoveryFetcher("devin-connect", realDevinDiscovery);globalThis.fetch = realFetch;});@@ -196,3 +233,45 @@ describe("providerServesModel live discovery", () => {expect(await providerServesModel(DISCOVERY_PROVIDER, "model-one")).toBe("not-served");});});++describe("providerServesModel resolver-backed discovery", () => {+ test("serves a canonical Devin family represented only by knob-encoded uids", async () => {+ stubDevinModelsCatalog();++ expect(devinModelsCatalog.map((model) => model.id)).toEqual([+ "swe-1-7",+ "swe-1-7-medium",+ ]);+ expect(devinModelsCatalog.some((model) => model.id === "swe-1.7")).toBe(false);+ expect(await providerServesModel("devin", "swe-1.7")).toBe("serves");+ });++ test("does not turn an unknown Devin family into a served model", async () => {+ stubDevinModelsCatalog();++ expect(await providerServesModel("devin", "not-a-devin-model")).toBe("not-served");+ });++ test("preserves exact-match behavior for a provider with no resolver", async () => {+ stubModelsCatalog("present-model");++ expect(await providerServesModel(DISCOVERY_PROVIDER, "present-model")).toBe("serves");+ expect(await providerServesModel(DISCOVERY_PROVIDER, "absent-model")).toBe("not-served");+ });++ test("keeps Devin primary when routing a bare canonical family", async () => {+ stubDevinModelsCatalog();+ credentials.isAvailable = async (provider: string) =>+ provider === "devin" || provider === "openrouter";+ credentials.describeReadiness = async (provider: string) => ({+ readiness: provider === "devin" || provider === "openrouter" ? "present" : "absent",+ });++ const plan = await route("swe-1.7", {}, "openrouter");++ expect(plan.kind).toBe("ok");+ if (plan.kind !== "ok") return;+ expect(plan.primary.provider).toBe("devin");+ expect(plan.primary.modelSpec).toBe("[email protected]");+ });+});diff --git a/packages/cli/src/providers/model-availability.ts b/packages/cli/src/providers/model-availability.tsindex 1d4efc02..a38a0b7f 100644--- a/packages/cli/src/providers/model-availability.ts+++ b/packages/cli/src/providers/model-availability.ts@@ -45,7 +45,12 @@ import { catalogRouteMatchesProvider } from "./catalog-route-bindings.js";*/import { getCatalogEntries } from "./catalog-client.js";-import { discoverProviderModels, getDiscoveryFailure } from "./model-discovery.js";+import {+ type DiscoveredModel,+ discoverProviderModels,+ getDiscoveryFailure,+} from "./model-discovery.js";+import { expandSelection } from "./model-resolvers/registry.js";import { getProviderByName } from "./provider-definitions.js";/**@@ -62,6 +67,39 @@ function modelsCatalogHas(ids: string[], wireId: string): boolean {return ids.some((id) => id.trim().toLowerCase() === needle);}+/**+ * The id this provider would ACTUALLY SEND for `wireId`, found by the same+ * resolver its transport uses.+ *+ * A provider that encodes knobs into its model ids never lists the bare+ * canonical id. Devin's dynamic models catalog holds `swe-1-7`,+ * `swe-1-7-medium` and `swe-1-7-lightning`, never `swe-1.7`, and its transport+ * maps the requested name onto one of them through `expandSelection` at request+ * time. This check used to compare the raw requested string instead, so it+ * answered "not-served" for every canonical id Devin carries, and "not-served"+ * is the one verdict allowed to REMOVE a candidate. Measured 2026-09-23 on a+ * 247-uid Devin catalog: `swe-1.7`, `swe-2`, `swe-1.6`, `glm-5.3` and+ * `kimi-k3` all read as not served, while the resolver maps them to+ * `swe-1-7-medium`, `swe-2-high`, `swe-1-6`, `glm-5-3-max` and `kimi-k3-high`.+ * A bare `swe-1.7` therefore lost its Devin hop and went to the OpenRouter+ * fallback, which answered "swe-1.7 is not a valid model ID", while the explicit+ * pin `[email protected]` worked.+ *+ * No effort is passed, so the resolver picks the family default. That is enough+ * to answer "is anything in this family served"; the transport resolves again+ * with the request's real effort when it sends. For a provider with no+ * resolver, `expandSelection` returns `wireId` unchanged, so their answer is+ * exactly what it was.+ */+function resolveAgainstModelsCatalog(+ provider: string,+ wireId: string,+ models: DiscoveredModel[]+): string {+ const entries = models.map(({ id, ...rest }) => ({ wireId: id, ...rest }));+ return expandSelection(provider, wireId, entries);+}+/*** Whether `provider` serves `wireId` — the id that would actually be SENT, not* the name the user typed. Callers hold the resolved spec already@@ -84,7 +122,7 @@ export async function providerServesModel(if (models.length > 0) {return modelsCatalogHas(models.map((m) => m.id),- wireId+ resolveAgainstModelsCatalog(provider, wireId, models))? "serves": "not-served";