Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix: ask an older Ollama daemon for capabilities it lists only in /api/show
Jack Rudenko50c7f0ed71ab
diff --git a/ai-docs/architecture/providers/qwen-alibaba.md b/ai-docs/architecture/providers/qwen-alibaba.mdindex 36bcee59..a3bc133f 100644--- a/ai-docs/architecture/providers/qwen-alibaba.md+++ b/ai-docs/architecture/providers/qwen-alibaba.md@@ -177,8 +177,10 @@ The vendor docs do carry capability hints in prose ("qwen3.7-plus (vision)",`happyhorse-1.1-t2v` = text-to-video), but transcribing those into source is thehardcoded model list the repo invariant forbids. `NON_CHAT_PATTERNS` caught every non-chatid on both live lists and missed exactly three, all video generators on editions the-measured account does not hold; only a cross-edition check found them. The video name-patterns in `providers/transport/probe-discovery.ts` cover them now.+measured account does not hold; only a cross-edition check found them. The name patterns+are gone since v10.1.1: chat capability now comes from the provider's own listing or the+catalog's published modalities (text among inputs AND outputs), and an id nothing+describes is not offered at all, so an undescribed video generator no longer slips through.## Measurement traps, all of which cost real timediff --git a/packages/cli/src/model-selector.test.ts b/packages/cli/src/model-selector.test.tsindex d7df467d..4267d54a 100644--- a/packages/cli/src/model-selector.test.ts+++ b/packages/cli/src/model-selector.test.ts@@ -34,6 +34,7 @@ import {type DiscoveredModel,type DiscoveryFailureKind,discoverProviderModels,+ discoverProviderModelsCatalog,getDiscoveryFailure,invalidateModelDiscovery,registerModelDiscoveryFetcher,@@ -43,6 +44,7 @@ import { BUILTIN_PROVIDERS, getProviderByName } from "./providers/provider-definimport { clearRuntimeRegistry, registerRuntimeProvider } from "./providers/runtime-providers.js";import {_clearChatCapabilityIndex,+ isReportedChatCapable,ollamaReported,} from "./providers/transport/probe-discovery.js";import { discoverProviderProbeModel } from "./providers/transport/provider-model-discovery.js";@@ -268,43 +270,97 @@ describe("provider-reported chat capability in discovered model callers", () =>});describe("Ollama discovery capability reports", () => {- const realFetch = globalThis.fetch;+ let realFetch: typeof globalThis.fetch;+ let realOllamaHost: string | undefined;beforeEach(() => {+ realFetch = globalThis.fetch;+ realOllamaHost = process.env.OLLAMA_HOST;+ process.env.OLLAMA_HOST = "http://ollama-picker.test";invalidateModelDiscovery("ollama");});afterEach(() => {globalThis.fetch = realFetch;+ if (realOllamaHost === undefined) delete process.env.OLLAMA_HOST;+ else process.env.OLLAMA_HOST = realOllamaHost;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([+ test("enriches missing tag capabilities before the picker filters discovered models", async () => {+ const showRequests: string[] = [];+ globalThis.fetch = mock(async (input: string | URL | Request, init?: RequestInit) => {+ const url = new URL(input instanceof Request ? input.url : String(input));+ if (url.pathname === "/api/tags") {+ return Response.json({+ models: [{ name: "llama3.2:3b" }, { name: "nomic-embed-text:latest" }],+ });+ }+ if (url.pathname === "/api/show") {+ const body = JSON.parse(String(init?.body)) as { name: string };+ showRequests.push(body.name);+ return Response.json({+ capabilities: body.name === "llama3.2:3b" ? ["completion", "tools"] : ["embedding"],+ });+ }+ throw new Error(`Unexpected fetch: ${url}`);+ }) as unknown as typeof fetch;++ const outcome = await discoverProviderModelsCatalog("ollama");++ expect(showRequests.sort()).toEqual(["llama3.2:3b", "nomic-embed-text:latest"].sort());+ expect(outcome.kind).toBe("served");+ if (outcome.kind !== "served") throw new Error("unreachable");+ expect(outcome.models).toEqual([{- id: "llama3.2:3b-q4_K_M",- displayName: "llama3.2:3b-q4_K_M",+ id: "llama3.2:3b",+ displayName: "llama3.2:3b",supportsTools: true,reported: "chat",},+ ]);+ expect(+ outcome.models.filter((model) => isReportedChatCapable(model.id, model.reported))+ ).toEqual(outcome.models);+ expect(outcome.models.map((model) => model.id)).not.toContain("nomic-embed-text:latest");+ });++ test("uses inline tag capabilities without requesting per-model details", async () => {+ let showRequests = 0;+ globalThis.fetch = mock(async (input: string | URL | Request) => {+ const url = new URL(input instanceof Request ? input.url : String(input));+ if (url.pathname === "/api/tags") {+ return Response.json({+ models: [+ { name: "llama3.2:3b", capabilities: ["completion", "tools"] },+ { name: "qwen2.5-coder:7b", capabilities: ["completion"] },+ ],+ });+ }+ if (url.pathname === "/api/show") {+ showRequests++;+ return Response.json({ capabilities: ["completion"] });+ }+ throw new Error(`Unexpected fetch: ${url}`);+ }) as unknown as typeof fetch;++ const outcome = await discoverProviderModelsCatalog("ollama");++ expect(showRequests).toBe(0);+ expect(outcome.kind).toBe("served");+ if (outcome.kind !== "served") throw new Error("unreachable");+ expect(outcome.models).toEqual([{- id: "granite3.2-vision:2b-instruct-q4_K_M",- displayName: "granite3.2-vision:2b-instruct-q4_K_M",+ id: "llama3.2:3b",+ displayName: "llama3.2:3b",+ supportsTools: true,+ reported: "chat",+ },+ {+ id: "qwen2.5-coder:7b",+ displayName: "qwen2.5-coder:7b",supportsTools: false,- reported: undefined,+ reported: "chat",},]);});diff --git a/packages/cli/src/model-selector.ts b/packages/cli/src/model-selector.tsindex 0f33a086..e94d202c 100644--- a/packages/cli/src/model-selector.ts+++ b/packages/cli/src/model-selector.ts@@ -472,9 +472,11 @@ function sortModelsNewestFirst(models: ModelInfo[]): ModelInfo[] {* accepts text and writes text is a chat model.** What is left to watch is the catalog being WRONG, so a row that survives but- * whose name reads like a generator — `seedance-2.5`, `flux-2-pro` — is named- * ONCE per process in the debug log. That decides nothing; it points at a- * catalog row to correct in models-index.+ * whose name reads like a generator family (seedance, flux, veo, imagen) is+ * named ONCE per process in the debug log. It decides nothing. Measured on+ * 2026-09-23, 3 of the 53 such rows publish `in: ["text"]`, `out: ["text"]`+ * (`flux-dev-finetuner`, `flux-fill`, `seedance-2.5-el`) — models-index rows+ * that need correcting, which is what this line is for.*/export function toPickerRows(models: ModelInfo[]): ModelInfo[] {const kept = sortModelsNewestFirst(dedupeModels(models.filter((m) => isChatCapable(m.id))));@@ -1470,7 +1472,8 @@ async function pickModelFromList(* - **Not everything served is chat.** Alibaba's plan host answers with image* and TTS models alongside chat ones. Filtered with the SAME predicate the* probe path uses, so the picker and `--probe` agree on what is chat-capable- * — a name-based rule, never a model-id skip list. An all-non-chat dynamic models catalog+ * — evidence from the provider's own listing or the catalog's modalities,+ * never a name rule or a model-id skip list. An all-non-chat dynamic models catalog* returns [] so the caller falls through to the catalog / free-text path* instead of showing an empty list.* - **Neither price nor (always) context is reported.** Context comes from thediff --git a/packages/cli/src/providers/model-discovery-builtins.ts b/packages/cli/src/providers/model-discovery-builtins.tsindex 6dff1e2c..958eaf75 100644--- a/packages/cli/src/providers/model-discovery-builtins.ts+++ b/packages/cli/src/providers/model-discovery-builtins.ts@@ -203,10 +203,12 @@ async function fetchOllamaModelsCatalog(): Promise<FetcherResult> {const { ollamaReported } = await import("./transport/probe-discovery.js");const endpoint = `${ollamaBaseUrl()}/api/tags`;try {- const installed = await fetchOllamaModels({- enrichCapabilities: false,- throwOnError: true,- });+ // `enrichCapabilities` is left at its default. It used to be `false`, which+ // cost nothing while an undescribed model still counted as chat — and hid+ // every model from a daemon that lists `capabilities` only in `/api/show`+ // once it stopped. A current daemon lists them inline, so the per-model+ // `/api/show` fallback never fires there.+ const installed = await fetchOllamaModels({ throwOnError: true });return {kind: "models",endpoint,diff --git a/packages/cli/src/providers/transport/anthropic-compat.ts b/packages/cli/src/providers/transport/anthropic-compat.tsindex 6c5fed1c..811caed4 100644--- a/packages/cli/src/providers/transport/anthropic-compat.ts+++ b/packages/cli/src/providers/transport/anthropic-compat.ts@@ -118,7 +118,8 @@ export class AnthropicProviderTransport implements ProviderTransport {* alphabetical tiebreak) — the same order the picker defaults to, so the* probe exercises the model the user would actually get.*- * Non-chat rows are dropped with the shared `isChatCapable()` filter rather+ * Non-chat rows are dropped by `discoverProviderProbeModel`, with the shared+ * `isReportedChatCapable()` filter the picker uses too, rather* than a per-provider skip list: qwen-token-plan's dynamic models catalog mixes* image/TTS models (`wan2.7-image`, `qwen-audio-3.0-tts-plus`) in with the text models, and* hardcoding model ids here would rot the moment Alibaba ships the next one.diff --git a/packages/cli/src/providers/transport/probe-discovery.ts b/packages/cli/src/providers/transport/probe-discovery.tsindex f7b0926a..c6c9126f 100644--- a/packages/cli/src/providers/transport/probe-discovery.ts+++ b/packages/cli/src/providers/transport/probe-discovery.ts@@ -81,10 +81,11 @@ function isSmallName(name: string): boolean {** Two sources of evidence, and no guesses: the provider's own published* capability for THIS deployment, and the cloud models catalog's published- * output modality for the canonical model.+ * input and output modalities for the canonical model — text must be among+ * both.*- * - `"not-chat"` — a provider or catalog statement that it produces something- * other than text, or a LiteLLM wildcard route. Never offered.+ * - `"not-chat"` — a provider or catalog statement that it produces no text, or+ * takes no text in, or a LiteLLM wildcard route. Never offered.* - `"chat"` — a provider or catalog statement that it answers chat turns.* - `"unknown"` — NOBODY said. Not offered either, and that is the point: an* unknown used to be treated as chat, so an embedding model nothing described@@ -157,8 +158,8 @@ function indexOutputModality(* File a catalog row's keys when its published INPUT modalities leave out text.** A chat model takes text in and gives text out; other modalities on either side- * never exclude one, so `["file","image","text"]` (every Claude model) is a chat- * model. What this catches is the other case: `gemini-3.5-transcribe` publishes+ * never exclude one, so `["file","image","text"]` and `["image","text"]` (two of+ * the lists Claude rows publish) are chat models. What this catches is the other case: `gemini-3.5-transcribe` publishes* `in: ["audio"]`, `out: ["text"]` — it writes text, but nothing typed reaches it.* Measured on the live catalog: 13 rows publish text output with no text input,* all ASR, captioning or live-translation models.