Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix: keep what a provider says about its own models, and three release-review findings

Jack Rudenko79817872238b
diff --git a/packages/cli/src/adapters/base-api-format.ts b/packages/cli/src/adapters/base-api-format.ts
index e2b51d75..e6fa23d9 100644
--- a/packages/cli/src/adapters/base-api-format.ts
+++ b/packages/cli/src/adapters/base-api-format.ts
@@ -792,8 +792,18 @@ export abstract class BaseAPIFormat implements APIFormat, ModelDialect {
): boolean {
if (effort !== "none" && effort !== "minimal") return false;
if (reasoning?.mandatory) return false;
- if (effort === "minimal" && (reasoning?.efforts?.length ?? 0) > 0) return false;
- return true;
+ if (effort === "none") return true;
+ // `minimal` is off only where "as little as possible" IS off: the model has
+ // no depth control at all, or the lowest rung it advertises is `none`. The
+ // second case was missed: `sakana-namazu` advertises `["high","none"]` under
+ // a toggle control, and `minimal` fell through and sent reasoning ON at full
+ // depth although its floor is off.
+ const advertised = (reasoning?.efforts ?? []).filter(isEffortLevel);
+ if (advertised.length === 0) return true;
+ const lowest = advertised.reduce((a, b) =>
+ EFFORT_ORDER.indexOf(a) <= EFFORT_ORDER.indexOf(b) ? a : b
+ );
+ return lowest === "none";
}
protected clampToAdvertisedEffort(
@@ -804,11 +814,17 @@ export abstract class BaseAPIFormat implements APIFormat, ModelDialect {
// escape hatch, and it can produce a 400: the clamp is what normally keeps
// a level the model does not advertise off the wire. Asking for it anyway
// is the user's explicit choice.
- // `--effort` pins the level VERBATIM — skip the clamp entirely. This is an
- // escape hatch, and it can produce a 400: the clamp is what normally keeps
- // a level the model does not advertise off the wire. Asking for it anyway
- // is the user's explicit choice.
- if (this.pinnedEffort) return this.pinnedEffort;
+ //
+ // Except `none` and `minimal`. Those two are DIRECTIONS — "off" and "the
+ // least there is" — and `meansReasoningOff` has already decided they reach
+ // this clamp only where the model cannot honour them literally. Sent
+ // verbatim they mean the opposite: GLM-5.2 runs any value other than `high`
+ // at Max, so a pinned `--effort minimal` bought maximum reasoning. Before
+ // `meansReasoningOff` existed, a pinned minimal never got here — it became
+ // the off switch first. Caught in release review for v10.0.2.
+ if (this.pinnedEffort && this.pinnedEffort !== "none" && this.pinnedEffort !== "minimal") {
+ return this.pinnedEffort;
+ }
const advertised = (reasoning.efforts ?? []).filter(isEffortLevel);
if (advertised.length === 0) {
return isEffortLevel(reasoning.defaultEffort) ? reasoning.defaultEffort : undefined;
@@ -876,6 +892,16 @@ export abstract class BaseAPIFormat implements APIFormat, ModelDialect {
return 38912;
case "max":
return undefined; // omit → model max
+ case "none":
+ case "minimal":
+ // The FLOOR, not the default. These two levels only reach a budget when
+ // the model cannot switch reasoning off (`mandatory`) or when `minimal`
+ // has a depth control to turn down, and in both cases the request is for
+ // the least thinking available. They used to fall to `default`'s 8192 —
+ // four times `low`'s 2048 — so asking for less bought more. Measured on
+ // the DashScope wire for qwen3.8-flash-next and qwen3.8-max-0902, caught
+ // in release review for v10.0.2.
+ return MIN_THINKING_BUDGET;
default:
return 8192;
}
diff --git a/packages/cli/src/adapters/effort-mapping.test.ts b/packages/cli/src/adapters/effort-mapping.test.ts
index db4639b1..f981e185 100644
--- a/packages/cli/src/adapters/effort-mapping.test.ts
+++ b/packages/cli/src/adapters/effort-mapping.test.ts
@@ -435,6 +435,20 @@ describe("Qwen enable_thinking + thinking_budget", () => {
);
});
+ test("a laddered optional model maps minimal to the 1024-token floor below low", () => {
+ const minimal = stubbedQwenPrep("qwen3-laddered", OPTIONAL_REASONING_LADDER, {
+ output_config: { effort: "minimal" },
+ });
+ const low = stubbedQwenPrep("qwen3-laddered", OPTIONAL_REASONING_LADDER, {
+ output_config: { effort: "low" },
+ });
+
+ expect(minimal.enable_thinking).toBe(true);
+ expect(minimal.thinking_budget).toBe(1024);
+ expect(low.thinking_budget).toBe(2048);
+ expect(minimal.thinking_budget).toBeLessThan(low.thinking_budget);
+ });
+
test("max omits the budget (model max)", () => {
const out = qwenPrep("qwen3-max", { output_config: { effort: "max" } });
expect(out.enable_thinking).toBe(true);
@@ -626,6 +640,27 @@ describe("GLM-5.2 catalog-driven reasoning_effort", () => {
expect(out.reasoning_effort).toBe("max");
});
+ test("a pinned minimal is clamped to GLM-5.2's advertised high floor", () => {
+ const format = new StubbedGLM("glm-5.2", CATALOG["glm-5.2"]);
+ format.setEffortOverride("minimal");
+
+ const out = format.prepareRequest({}, { output_config: { effort: "max" } });
+
+ expect(out.thinking).toEqual({ type: "enabled" });
+ expect(out.reasoning_effort).toBe("high");
+ expect(out.reasoning_effort).not.toBe("minimal");
+ });
+
+ test("a pinned depth level remains a verbatim escape hatch", () => {
+ const format = new StubbedGLM("glm-5.2", CATALOG["glm-5.2"]);
+ format.setEffortOverride("xhigh");
+
+ const out = format.prepareRequest({}, { output_config: { effort: "minimal" } });
+
+ expect(out.thinking).toEqual({ type: "enabled" });
+ expect(out.reasoning_effort).toBe("xhigh");
+ });
+
test("glm-5.2-fast has the same effort mapping as glm-5.2", () => {
for (const effort of ["none", "minimal", "low", "medium", "high", "xhigh", "max"] as const) {
const regular = stubbedGlmPrep("glm-5.2", CATALOG["glm-5.2"], {
@@ -695,6 +730,39 @@ describe("shared reasoning-off rule on the GLM wire", () => {
// The matching toggle results are deliberate, not a collapse of minimal into none.
expect(minimal.thinking).not.toEqual(ladderMinimal.thinking);
});
+
+ test("an Anthropic toggle whose lowest advertised rung is none turns minimal off", () => {
+ const out = stubbedGlmPrep(
+ "sakana-namazu",
+ {
+ supported: true,
+ control: "toggle",
+ mandatory: false,
+ efforts: ["high", "none"],
+ },
+ { output_config: { effort: "minimal" } },
+ {},
+ "anthropic-sse"
+ );
+
+ expect(out.thinking).toEqual({ type: "disabled" });
+ });
+
+ test("an Anthropic mandatory ladder never emits the off switch for none or minimal", () => {
+ for (const effort of ["none", "minimal"] as const) {
+ const out = stubbedGlmPrep(
+ "glm-5.3",
+ MANDATORY_REASONING_LADDER,
+ { output_config: { effort } },
+ {},
+ "anthropic-sse"
+ );
+
+ expect(out.thinking).toEqual({ type: "enabled" });
+ expect(out.thinking).not.toEqual({ type: "disabled" });
+ expect(out.output_config?.effort).toBe("low");
+ }
+ });
});
describe("GLM legacy stripping behavior", () => {
diff --git a/packages/cli/src/handlers/shared/anthropic-error.test.ts b/packages/cli/src/handlers/shared/anthropic-error.test.ts
index 1b8ac701..4f1c80b7 100644
--- a/packages/cli/src/handlers/shared/anthropic-error.test.ts
+++ b/packages/cli/src/handlers/shared/anthropic-error.test.ts
@@ -289,16 +289,46 @@ describe("ensureAnthropicErrorFormat", () => {
});
describe("extractProviderMessage", () => {
- it("unwraps a nested SSE frame while preserving an ordinary string", () => {
+ it("preserves an ordinary string", () => {
expect(extractProviderMessage("plain error")).toBe("plain error");
- expect(
- extractProviderMessage({
+ });
+
+ it.each([
+ [
+ "multi-line",
+ 'event:error\ndata:{"code":"AccessDenied","message":"Model access denied.","request_id":"x"}',
+ ],
+ [
+ "flattened",
+ 'event:error data:{"code":"AccessDenied","message":"Model access denied.","request_id":"x"}',
+ ],
+ [
+ "flattened inside error.message",
+ {
error: {
message:
'event:error data:{"code":"AccessDenied","message":"Model access denied.","request_id":"x"}',
},
+ },
+ ],
+ ])("unwraps a real %s SSE frame", (_shape, body) => {
+ expect(extractProviderMessage(body)).toBe("Model access denied.");
+ });
+
+ it("does not truncate a FastAPI detail sentence containing data:", () => {
+ expect(extractProviderMessage({ detail: "Missing key in request data: messages" })).toBe(
+ "Missing key in request data: messages"
+ );
+ });
+
+ it("does not truncate a nested error message containing a data: URL reference", () => {
+ expect(
+ extractProviderMessage({
+ error: {
+ message: "Invalid content block: data: URLs are not supported for this model",
+ },
})
- ).toBe("Model access denied.");
+ ).toBe("Invalid content block: data: URLs are not supported for this model");
});
it("pulls error.message from OpenAI-style bodies", () => {
diff --git a/packages/cli/src/handlers/shared/anthropic-error.ts b/packages/cli/src/handlers/shared/anthropic-error.ts
index 94a45379..ac61b53f 100644
--- a/packages/cli/src/handlers/shared/anthropic-error.ts
+++ b/packages/cli/src/handlers/shared/anthropic-error.ts
@@ -187,7 +187,14 @@ export function extractUpstreamStatus(body: string): number | undefined {
* per the SSE specification.
*/
export function sseDataPayload(body: string): string | undefined {
- if (!/(^|\s)(event|data):/.test(body)) return undefined;
+ // Anchored to the START of the text. An SSE frame begins with its field name;
+ // an ordinary error sentence merely CONTAINS " data:", and the unanchored
+ // detector sliced such a sentence at that point: `"Missing key in request data:
+ // messages"` came back as `"messages"`, and `"Invalid content block: data: URLs
+ // are not supported"` lost everything before "URLs". That cut-down text is what
+ // Claude Code shows, so the reader got a fragment instead of the provider's
+ // sentence. Caught in release review for v10.0.2.
+ if (!/^\s*(event|data):/.test(body)) return undefined;
// Shape 1: a real frame, still carrying its line breaks. Multiple `data:`
// lines concatenate, per the specification.
diff --git a/packages/cli/src/model-selector.test.ts b/packages/cli/src/model-selector.test.ts
index 9b24851e..1ce45257 100644
--- a/packages/cli/src/model-selector.test.ts
+++ b/packages/cli/src/model-selector.test.ts
@@ -19,6 +19,7 @@ import {
} from "./handlers/shared/remote-provider-types.js";
import {
type ModelInfo,
+ buildDiscoveredModelRows,
buildExplicitModelSpec,
buildProviderChoices,
getProviderFilterAliases,
@@ -30,13 +31,21 @@ import {
} from "./model-selector.js";
import { createCatalogClient } from "./providers/model-catalog.js";
import {
+ type DiscoveredModel,
type DiscoveryFailureKind,
discoverProviderModels,
getDiscoveryFailure,
invalidateModelDiscovery,
+ registerModelDiscoveryFetcher,
} from "./providers/model-discovery.js";
import { parseModelSpec } from "./providers/model-parser.js";
import { BUILTIN_PROVIDERS, getProviderByName } from "./providers/provider-definitions.js";
+import { clearRuntimeRegistry, registerRuntimeProvider } from "./providers/runtime-providers.js";
+import {
+ _clearChatCapabilityIndex,
+ ollamaReported,
+} from "./providers/transport/probe-discovery.js";
+import { discoverProviderProbeModel } from "./providers/transport/provider-model-discovery.js";
// ─── pickerProviderToFirebaseSlug ────────────────────────────────────────────
@@ -165,6 +174,148 @@ describe("warnDiscoveryFailure", () => {
);
});
+describe("provider-reported chat capability in discovered model callers", () => {
+ const provider = "reported-capability-test";
+ const format = "reported-capability-test-format";
+ let discovered: DiscoveredModel[] = [];
+
+ const catalog = createCatalogClient({
+ getModelsByProvider: async () => {
+ throw new Error("local discovered rows must not query the cloud catalog");
+ },
+ readSlimCache: () => null,
+ });
+
+ beforeEach(() => {
+ invalidateModelDiscovery();
+ clearRuntimeRegistry();
+ _clearChatCapabilityIndex();
+ discovered = [];
+
+ const localTemplate = getProviderByName("ollama")!;
+ registerRuntimeProvider({
+ ...localTemplate,
+ name: provider,
+ displayName: "Reported Capability Test",
+ shortcuts: [],
+ legacyPrefixes: [],
+ modelDiscovery: {
+ path: "",
+ format: format as "ollama-tags",
+ },
+ });
+ registerModelDiscoveryFetcher(format, async () => discovered);
+ });
+
+ afterEach(() => {
+ invalidateModelDiscovery();
+ clearRuntimeRegistry();
+ _clearChatCapabilityIndex();
+ });
+
+ test("buildDiscoveredModelRows keeps catalog-unknown rows reported as chat", async () => {
+ discovered = [
+ { id: "swe-1-7-medium", reported: "chat" },
+ { id: "gemini-3.6-flash-high", reported: "chat" },
+ { id: "llama3.2:3b-q4_K_M", reported: "chat" },
+ ];
+
+ const rows = await buildDiscoveredModelRows(provider, "Reported Capability Test", catalog);
+
+ expect(rows.map((row) => row.id).sort()).toEqual(
+ ["swe-1-7-medium", "gemini-3.6-flash-high", "llama3.2:3b-q4_K_M"].sort()
+ );
+ });
+
+ test("buildDiscoveredModelRows drops a row reported as not-chat", async () => {
+ discovered = [{ id: "nomic-embed-text:latest", reported: "not-chat" }];
+
+ expect(await buildDiscoveredModelRows(provider, "Reported Capability Test", catalog)).toEqual(
+ []
+ );
+ });
+
+ test("buildDiscoveredModelRows still drops a catalog-unknown row with no report", async () => {
+ discovered = [{ id: "granite3.2-vision:2b-instruct-q4_K_M" }];
+
+ expect(await buildDiscoveredModelRows(provider, "Reported Capability Test", catalog)).toEqual(
+ []
+ );
+ });
+
+ test("discoverProviderProbeModel picks from catalog-unknown rows reported as chat", async () => {
+ discovered = [
+ { id: "swe-1-7-medium", reported: "chat" },
+ { id: "gemini-3.6-flash-high", reported: "chat" },
+ { id: "llama3.2:3b-q4_K_M", reported: "chat" },
+ ];
+
+ const outcome = await discoverProviderProbeModel(provider, "Reported Capability Test");
+
+ expect(outcome.model).not.toBeNull();
+ expect(discovered.map((row) => row.id)).toContain(outcome.model!);
+ expect(outcome.reason).toBeUndefined();
+ });
+
+ test("discoverProviderProbeModel still rejects a catalog-unknown row with no report", async () => {
+ discovered = [{ id: "granite3.2-vision:2b-instruct-q4_K_M" }];
+
+ expect(await discoverProviderProbeModel(provider, "Reported Capability Test")).toEqual({
+ model: null,
+ reason: "no chat-capable model among the 1 listed by Reported Capability Test",
+ });
+ });
+});
+
+describe("Ollama discovery capability reports", () => {
+ const realFetch = globalThis.fetch;
+
+ beforeEach(() => {
+ invalidateModelDiscovery("ollama");
+ });
+
+ afterEach(() => {
+ globalThis.fetch = realFetch;
+ invalidateModelDiscovery("ollama");
+ });
+
+ test("the Ollama fetcher carries completion reports and preserves an absent capability", async () => {
+ globalThis.fetch = mock(
+ async () =>
+ new Response(
+ JSON.stringify({
+ models: [
+ { name: "llama3.2:3b-q4_K_M", capabilities: ["completion", "tools"] },
+ { name: "granite3.2-vision:2b-instruct-q4_K_M" },
+ ],
+ }),
+ { status: 200 }
+ )
+ ) as unknown as typeof fetch;
+
+ expect(await discoverProviderModels("ollama")).toEqual([
+ {
+ id: "llama3.2:3b-q4_K_M",
+ displayName: "llama3.2:3b-q4_K_M",
+ supportsTools: true,
+ reported: "chat",
+ },
+ {
+ id: "granite3.2-vision:2b-instruct-q4_K_M",
+ displayName: "granite3.2-vision:2b-instruct-q4_K_M",
+ supportsTools: false,
+ reported: undefined,
+ },
+ ]);
+ });
+
+ test("ollamaReported maps completion, embedding, and silence", () => {
+ expect(ollamaReported({ capabilities: ["completion", "tools"] })).toBe("chat");
+ expect(ollamaReported({ capabilities: ["embedding"] })).toBe("not-chat");
+ expect(ollamaReported({})).toBeUndefined();
+ });
+});
+
describe("buildExplicitModelSpec", () => {
test.each([
["zen", "claude-opus-4-7", "zen@claude-opus-4-7"],
diff --git a/packages/cli/src/model-selector.ts b/packages/cli/src/model-selector.ts
index 0527ba12..193cf76b 100644
--- a/packages/cli/src/model-selector.ts
+++ b/packages/cli/src/model-selector.ts
@@ -49,7 +49,7 @@ import {
getProviderByName,
} from "./providers/provider-definitions.js";
import { getRuntimeProviders } from "./providers/runtime-providers.js";
-import { isChatCapable } from "./providers/transport/probe-discovery.js";
+import { isReportedChatCapable } from "./providers/transport/probe-discovery.js";
/**
* Model data structure
@@ -1335,8 +1335,12 @@ export async function buildDiscoveredModelRows(
displayName: string,
catalog: CatalogClient
): Promise<ModelInfo[]> {
+ // `m.reported` carries the provider's own chat/not-chat statement. Judging the
+ // bare `m.id` alone discarded it, and once `unknown` stopped counting as chat
+ // that emptied the picker for every provider whose ids the cloud catalog does
+ // not list verbatim: Ollama 19 → 1, Devin 247 → 3, Antigravity 21 → 7.
const discovered = rankDiscoveredModels(await discoverProviderModels(provider)).filter((m) =>
- isChatCapable(m.id)
+ isReportedChatCapable(m.id, m.reported)
);
if (discovered.length === 0) return [];
diff --git a/packages/cli/src/providers/model-discovery-builtins.ts b/packages/cli/src/providers/model-discovery-builtins.ts
index 10454159..f024cf90 100644
--- a/packages/cli/src/providers/model-discovery-builtins.ts
+++ b/packages/cli/src/providers/model-discovery-builtins.ts
@@ -36,7 +36,12 @@ async function fetchDevinModelsCatalog(): Promise<DiscoveredModel[]> {
const { devinModelsCatalogEntry } = await import("./model-resolvers/devin.js");
return served.map((model) => {
const { wireId, ...rest } = devinModelsCatalogEntry(model);
- return { id: wireId, ...rest };
+ // `chat` is Devin's statement, not ours. This list is the set of models
+ // Devin's own agent can drive — capability ∩ entitlement, already filtered
+ // to configs with a context window — so every uid in it answers chat turns.
+ // Its uids are knob-encoded (`swe-1-7-medium`) and the cloud catalog never
+ // lists them verbatim, so judged by id alone 244 of 247 read as unknown.
+ return { id: wireId, ...rest, reported: "chat" as const };
});
}
@@ -91,20 +96,37 @@ async function fetchAntigravityModelsCatalog(): Promise<DiscoveredModel[]> {
// than the row rendering a fabricated 0 as "N/A".
// Every id here is a tuned variant (`-high`, `-tiered`) the catalog does not
// carry; see `ignoreCatalogReleaseDate` for the ordering this protects.
+ // `chat` is the backend's statement: everything it declares non-selectable —
+ // internal flags, per-feature role bindings, retired ids — was removed above,
+ // and so were the undeclared editor-completion models. What remains is the
+ // set it offers for chat. Judged by id alone, 14 of 21 read as unknown,
+ // because these tuned variants are ids the cloud catalog does not carry.
return m?.contextWindow
- ? { id, contextWindow: m.contextWindow, ignoreCatalogReleaseDate: true }
- : { id, ignoreCatalogReleaseDate: true };
+ ? {
+ id,
+ contextWindow: m.contextWindow,
+ ignoreCatalogReleaseDate: true,
+ reported: "chat" as const,
+ }
+ : { id, ignoreCatalogReleaseDate: true, reported: "chat" as const };
});
}
/** Ollama's daemon speaks its own listing shape and carries capability data no OpenAI list has. */
async function fetchOllamaModelsCatalog(): Promise<DiscoveredModel[]> {
const { fetchOllamaModels } = await import("./ollama-discovery.js");
+ const { ollamaReported } = await import("./transport/probe-discovery.js");
const installed = await fetchOllamaModels({ enrichCapabilities: false });
return installed.map((model) => ({
id: model.name,
displayName: model.name,
supportsTools: model.supportsTools,
+ // The daemon's own `capabilities`, read from `/api/tags`: `completion` means
+ // chat, `embedding` means not. This row used to carry only name, display name
+ // and a tools flag, so the capability data was fetched and then dropped here,
+ // and 18 of 19 local builds — none of which the cloud catalog lists — read as
+ // unknown. A daemon too old to report the field leaves it unset.
+ reported: ollamaReported(model),
}));
}
diff --git a/packages/cli/src/providers/model-discovery.ts b/packages/cli/src/providers/model-discovery.ts
index 9b80b18d..7dc32f74 100644
--- a/packages/cli/src/providers/model-discovery.ts
+++ b/packages/cli/src/providers/model-discovery.ts
@@ -29,6 +29,7 @@ import { VERSION } from "../version.js";
import { compareByReleaseDateDesc } from "./model-ordering.js";
import type { ModelOffer, ModelsCatalogAxis, ModelsCatalogEntry } from "./model-resolvers/types.js";
import { getProviderByName } from "./provider-definitions.js";
+import type { ReportedCapability } from "./transport/probe-discovery.js";
/** A model as reported by the provider's own live endpoint. */
export interface DiscoveredModel {
@@ -72,6 +73,21 @@ export interface DiscoveredModel {
* "newest first".
*/
ignoreCatalogReleaseDate?: boolean;
+ /**
+ * What the PROVIDER said about whether this model answers chat turns, when it
+ * said anything. Set by the discovery fetcher that holds the evidence, and read
+ * by every caller that filters a dynamic models catalog for chat models.
+ *
+ * It exists because those callers used to strip each row to its bare `id`
+ * before judging it, and a bare id judged alone is `"unknown"` for exactly the
+ * ids a provider invents: Ollama's local `name:tag` builds, Devin's
+ * knob-encoded uids (`swe-1-7-medium`), Antigravity's tuned variants
+ * (`gemini-3.6-flash-high`). Once `unknown` stopped counting as chat, those
+ * rows vanished from the picker — measured 2026-09-23: Ollama 19 → 1,
+ * Devin 247 → 3, Antigravity 21 → 7 — although every one of those providers had
+ * stated what its models were. `undefined` is a silence and stays one.
+ */
+ reported?: ReportedCapability;
/**
* Variant metadata, for providers that encode knobs INTO their model ids.
*
diff --git a/packages/cli/src/providers/transport/probe-discovery.ts b/packages/cli/src/providers/transport/probe-discovery.ts
index 5618ee6d..e2126385 100644
--- a/packages/cli/src/providers/transport/probe-discovery.ts
+++ b/packages/cli/src/providers/transport/probe-discovery.ts
@@ -58,7 +58,7 @@ export type ReportedCapability = "chat" | "not-chat" | undefined;
* means it answers chat turns; `embedding` means it does not. An empty or
* missing array is a silence, never a denial — older daemons omit the field.
*/
-function ollamaReported(row: { capabilities?: unknown }): ReportedCapability {
+export function ollamaReported(row: { capabilities?: unknown }): ReportedCapability {
const caps = Array.isArray(row.capabilities) ? (row.capabilities as string[]) : [];
if (caps.includes("completion")) return "chat";
if (caps.includes("embedding")) return "not-chat";
diff --git a/packages/cli/src/providers/transport/provider-model-discovery.ts b/packages/cli/src/providers/transport/provider-model-discovery.ts
index 041105d9..ec8736fb 100644
--- a/packages/cli/src/providers/transport/provider-model-discovery.ts
+++ b/packages/cli/src/providers/transport/provider-model-discovery.ts
@@ -5,7 +5,7 @@ import {
rankDiscoveredModels,
} from "../model-discovery.js";
import { getProviderByName } from "../provider-definitions.js";
-import { type DiscoveryOutcome, isChatCapable } from "./probe-discovery.js";
+import { type DiscoveryOutcome, isReportedChatCapable } from "./probe-discovery.js";
/**
* Pick a probe model from one provider's authenticated, account-scoped dynamic models catalog.
@@ -39,9 +39,13 @@ export async function discoverProviderProbeModel(
};
}
+ // Judge each row WITH the provider's own statement before reducing it to an
+ // id. The old order — `.map(id).filter(isChatCapable)` — discarded `reported`
+ // first, so a provider that had described every model still lost the ones the
+ // cloud catalog does not list verbatim, and the probe found nothing to pick.
const ranked = rankDiscoveredModels(discovered)
- .map((model) => model.id)
- .filter(isChatCapable);
+ .filter((model) => isReportedChatCapable(model.id, model.reported))
+ .map((model) => model.id);
if (ranked.length === 0) {
return {
model: null,