Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: recognise embedding models that name no "embed" marker

Adam Eivy1567f96a2d4c
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 8e221ddaa6..484ce9b1d4 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -483,7 +483,10 @@ export const isEmbeddingModel = (id) =>
// Mirror of EMBEDDING_RE in server/lib/localModelHeuristics.js — keep in lockstep.
// `embeddinggemma` needs its own alternative: the anchored `embedding` marker
// requires a separator after it, and that id glues the family straight on.
- /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5|snowflake-arctic-embed)(?:[-_/:]|$)|text-embedding|embeddinggemma/i.test(id);
+ // `minilm` / `paraphrase-multilingual` carry no `embed` marker at all —
+ // `all-minilm` and `paraphrase-multilingual` are Ollama embedding models that
+ // would otherwise be offered in a chat/generation picker.
+ /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5|snowflake-arctic-embed)(?:[-_/:]|$)|text-embedding|embeddinggemma|minilm|paraphrase-multilingual/i.test(id);
/**
* Vision-capable (multimodal) model detector — mirror of `isVisionModel` in
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 7dad365568..8eba7bc330 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -673,10 +673,20 @@ describe('isEmbeddingModel / filterGenerationModels', () => {
expect(isEmbeddingModel('')).toBe(false);
});
+ // These name no `embed` marker at all, so the anchored markers miss them and
+ // they read as chat models — the picker would offer `all-minilm`, and the
+ // daemon answers `400 "all-minilm:latest" does not support chat`.
+ it('flags embedding models whose id carries no embed marker', () => {
+ expect(isEmbeddingModel('all-minilm:latest')).toBe(true);
+ expect(isEmbeddingModel('all-minilm:33m')).toBe(true);
+ expect(isEmbeddingModel('paraphrase-multilingual:latest')).toBe(true);
+ });
+
it('drops sentinels and embedding models from generation lists', () => {
expect(filterGenerationModels([
CODEX_CONFIGURED_DEFAULT,
'nomic-embed-text:latest',
+ 'all-minilm:latest',
'qwen3.6:35b',
'llama3.2:latest',
])).toEqual(['qwen3.6:35b', 'llama3.2:latest']);
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 99433adf02..02445a1456 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -160,8 +160,11 @@ const ERROR_PATTERNS = [
// healthy daemon plus a tier-4 investigation task. It is the same class of
// fault as an unknown model id — this request named the wrong model for
// this endpoint — so it belongs here, where the cooldown treats it as
- // request-specific and tier 1 corrects the model instead.
- pattern: /model.*(not found|does not exist|unavailable)|invalid model|model identifier is invalid|does not support (?:chat|generate|completions?|embeddings?)/i,
+ // request-specific and tier 1 corrects the model instead. The other
+ // operations Ollama names the same way (`insert`, `tools`, `thinking`) are
+ // the same fault — a model asked for something it cannot do — and were
+ // still landing in UNKNOWN.
+ pattern: /model.*(not found|does not exist|unavailable)|invalid model|model identifier is invalid|does not support (?:chat|generate|completions?|embeddings?|insert|tools|thinking)/i,
category: ERROR_CATEGORIES.MODEL_NOT_FOUND,
requiresFallback: true,
actionable: true,
@@ -708,20 +711,34 @@ export function createImmediateFallbackSignalDetector({ maxBuffer = 512 } = {})
};
}
+// Undo JSON string escaping in a value lifted out of a raw error BODY. One pass,
+// so an escaped backslash can't be re-read as the start of the next escape
+// (`C:\\ntemp` stays a path, not a newline). Only the `json: true` patterns
+// below use it — a plain `Error: …` line is literal text, and unescaping it
+// would rewrite a Windows path.
+const JSON_STRING_ESCAPES = { n: '\n', t: '\t', r: '\r', b: '\b', f: '\f' };
+const unescapeJsonString = (value) =>
+ value.replace(/\\(.)/g, (_, ch) => JSON_STRING_ESCAPES[ch] ?? ch);
+
function extractErrorMessage(text) {
if (!text) return '';
const patterns = [
- /Error:\s*(.+?)(?:\n|$)/i,
- /error":\s*"([^"]+)"/i,
- /message":\s*"([^"]+)"/i,
- /failed:\s*(.+?)(?:\n|$)/i
+ { re: /Error:\s*(.+?)(?:\n|$)/i },
+ // A JSON error body routinely ESCAPES quotes inside the value — Ollama
+ // reports `{"error":"\"all-minilm:latest\" does not support chat"}`. A
+ // `[^"]+` value stops at that first escaped quote and returns a lone
+ // backslash as "the message", which is what a log line and an investigation
+ // task then carried instead of the actual sentence. Consume escape pairs.
+ { re: /error":\s*"((?:[^"\\]|\\.)+)"/i, json: true },
+ { re: /message":\s*"((?:[^"\\]|\\.)+)"/i, json: true },
+ { re: /failed:\s*(.+?)(?:\n|$)/i }
];
- for (const pattern of patterns) {
- const match = text.match(pattern);
+ for (const { re, json } of patterns) {
+ const match = text.match(re);
if (match) {
- return match[1].trim();
+ return (json ? unescapeJsonString(match[1]) : match[1]).trim();
}
}
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index e6d4bb8014..f5c2bb823f 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -43,6 +43,36 @@ describe('Error Detection', () => {
expect(result.category).toBe(ERROR_CATEGORIES.UNKNOWN);
});
+ // A local daemon rejecting an OPERATION the model cannot perform. Untriaged
+ // this landed in UNKNOWN, which is not request-specific: one bad model id
+ // benched the whole Ollama provider (taking every OTHER model on it offline)
+ // and raised a Tier-4 investigation task for a failure fully determined by
+ // the model id.
+ it('classifies an Ollama embedding model asked to chat, message intact', () => {
+ const result = analyzeError('Ollama returned 400: {"error":"\\"all-minilm:latest\\" does not support chat"}', 1);
+ expect(result.hasError).toBe(true);
+ expect(result.category).toBe(ERROR_CATEGORIES.MODEL_NOT_FOUND);
+ expect(result.requiresFallback).toBe(true);
+ expect(result.actionable).toBe(true);
+ // The escaped quotes in the JSON body must not eat the message.
+ expect(result.message).toBe('"all-minilm:latest" does not support chat');
+ });
+
+ it('detects the unquoted and other-operation forms too', () => {
+ for (const text of [
+ 'Ollama returned 400: {"error":"nomic-embed-text:latest does not support chat"}',
+ '{"error":"smollm:135m does not support tools"}',
+ "'gemma4:e4b' does not support insert",
+ ]) {
+ expect(analyzeError(text, 1).category, text).toBe(ERROR_CATEGORIES.MODEL_NOT_FOUND);
+ }
+ });
+
+ it('leaves an unrelated unsupported-feature line in the unknown bucket', () => {
+ expect(analyzeError('Note: this API does not support streaming yet.', 1).category)
+ .toBe(ERROR_CATEGORIES.UNKNOWN);
+ });
+
it('should detect rate limit errors', () => {
const result = analyzeError('API Error: 429 Too Many Requests');
expect(result.hasError).toBe(true);
diff --git a/server/lib/localModelAssessment.js b/server/lib/localModelAssessment.js
index 5aa414427b..a61a5ef286 100644
--- a/server/lib/localModelAssessment.js
+++ b/server/lib/localModelAssessment.js
@@ -24,8 +24,13 @@
*
* Anything that conflates those makes an unassessed model look worse than a
* measured-bad one, which is the exact failure this feature exists to remove.
+ *
+ * (Dependency-free apart from `localModelHeuristics.js`, which is itself pure —
+ * a sweep has to know which installed models are even *assessable*.)
*/
+import { isEmbeddingModel } from './localModelHeuristics.js';
+
/**
* Fit verdicts. Deliberately four values, not a boolean:
* - `fits` — at least one context length generated successfully
@@ -570,6 +575,14 @@ export function selectSweepTargets({ assessments = [], unassessed = [], scope =
const add = (target) => {
const key = targetKey(target);
if (!target.backend || !target.modelId || seen.has(key)) return;
+ // An assessment measures a model by GENERATING with it, so an embedding-only
+ // model has no measurement to take: the daemon answers every sample with
+ // `400 "<model>" does not support chat`, the record lands as `incompatible`
+ // (which reads as "this machine can't run it" — it can, that is just not
+ // what it does), and each doomed sample raises an AI-provider investigation
+ // task. Excluded from BOTH branches, so a bogus record written before this
+ // existed is not re-queued forever by the `stale`/`all` scopes.
+ if (isEmbeddingModel(target.modelId)) return;
seen.add(key);
targets.push(target);
};
diff --git a/server/lib/localModelAssessment.test.js b/server/lib/localModelAssessment.test.js
index 2908a69df3..b60c2144df 100644
--- a/server/lib/localModelAssessment.test.js
+++ b/server/lib/localModelAssessment.test.js
@@ -755,6 +755,56 @@ describe('selectSweepTargets', () => {
const targets = selectSweepTargets({ assessments: [], unassessed, scope: 'unmeasured', tunings: [] });
expect(targets.map((t) => t.modelId)).toEqual(['new-model']);
});
+
+ // ---- embedding models are not assessable ---------------------------------
+ // An assessment measures a model by GENERATING with it. Ollama answers every
+ // sample aimed at an embedding-only model with
+ // `400 "<model>" does not support chat`, so the whole measurement is doomed
+ // from the model id alone — and each doomed sample raised an AI-provider
+ // investigation task and briefly benched the provider.
+ it('never queues an embedding model for the unmeasured scope', () => {
+ const targets = selectSweepTargets({
+ assessments: [],
+ unassessed: [
+ { backend: 'ollama', modelId: 'all-minilm:latest' },
+ { backend: 'ollama', modelId: 'nomic-embed-text:latest' },
+ { backend: 'ollama', modelId: 'qwen3.6:35b' },
+ ],
+ scope: 'unmeasured',
+ });
+ expect(targets.map((t) => t.modelId)).toEqual(['qwen3.6:35b']);
+ });
+
+ // A bogus record written before the filter existed must not be re-queued
+ // forever by the scopes that re-measure stored readings.
+ it('never re-queues a stored embedding-model reading', () => {
+ const embedRecord = {
+ backend: 'ollama', modelId: 'all-minilm:latest', tuningKey: '', tuningLabel: null,
+ tuning: {}, staleness: { stale: true },
+ };
+ expect(selectSweepTargets({ assessments: [embedRecord], unassessed: [], scope: 'stale' })).toEqual([]);
+ expect(selectSweepTargets({ assessments: [embedRecord], unassessed: [], scope: 'all' })).toEqual([]);
+ });
+
+ it('refuses a named embedding model even though naming one implies the all scope', () => {
+ const targets = selectSweepTargets({
+ assessments: [], unassessed: [{ backend: 'ollama', modelId: 'all-minilm:latest' }],
+ scope: 'unmeasured', only: { backend: 'ollama', modelId: 'all-minilm:latest' },
+ });
+ expect(targets).toEqual([]);
+ });
+
+ it('keeps an embedding model out of the tuning cross too', () => {
+ const targets = selectSweepTargets({
+ assessments: [], unassessed: [
+ { backend: 'ollama', modelId: 'all-minilm:latest' },
+ { backend: 'ollama', modelId: 'qwen3.6:35b' },
+ ],
+ scope: 'unmeasured', tunings: grid,
+ });
+ expect(targets.map((t) => `${t.modelId}@${t.tuningKey}`))
+ .toEqual(['qwen3.6:35b@', 'qwen3.6:35b@flashAttn=true']);
+ });
});
describe('summarizeSweepScopes', () => {
diff --git a/server/lib/localModelHeuristics.js b/server/lib/localModelHeuristics.js
index 07190c3ee6..695bf0512a 100644
--- a/server/lib/localModelHeuristics.js
+++ b/server/lib/localModelHeuristics.js
@@ -19,24 +19,67 @@
// `embeddinggemma` glues the marker to the family with no separator, so the
// anchored `embedding` alternative misses it — match that name explicitly or it
// reads as a chat-capable Gemma and gets picked for generation.
+// `minilm` / `paraphrase-multilingual` carry no `embed` marker at all
+// (`all-minilm`, `paraphrase-multilingual` are two of Ollama's own embedding
+// models) — matched by family, or they read as chat models and get benchmarked
+// or picked for generation, which the daemon answers with
+// `400 "…" does not support chat`.
const EMBEDDING_RE =
- /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5|snowflake-arctic-embed)(?:[-_/:]|$)|text-embedding|embeddinggemma/i;
+ /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5|snowflake-arctic-embed)(?:[-_/:]|$)|text-embedding|embeddinggemma|minilm|paraphrase-multilingual/i;
+
+// `embedding` is Ollama's raw capability name; `embeddings` is the badge label a
+// normalized PortOS model card carries (and LM Studio's `type`).
+const isEmbeddingCapability = (value) => {
+ const normalized = value ? String(value).toLowerCase() : '';
+ return normalized === 'embedding' || normalized === 'embeddings';
+};
/**
- * @param {string} id model id (e.g. "nomic-embed-text:latest")
- * @returns {boolean} true when the id names an embedding-only model
+ * Detect an embedding-only model from its id and/or backend capability
+ * metadata. Prefers explicit metadata, exactly like `isVisionModel` /
+ * `isToolUseModel`: Ollama's `/api/show` reports `capabilities: ['embedding']`
+ * for an embedding model and e.g. `['completion','tools','thinking']` for a
+ * chat model, so a non-empty array is authoritative in BOTH directions and the
+ * id regex is only the fallback for bare id strings (LM Studio, a stored
+ * provider `models` list, `/api/tags` with no enrichment).
+ *
+ * @param {string|{id?:string,name?:string,capabilities?:string[]}} model
+ * model id (e.g. "nomic-embed-text:latest") or a model card
+ * @returns {boolean} true when the model is embedding-only
*/
-export function isEmbeddingModel(id) {
+export function isEmbeddingModel(model) {
+ if (!model) return false;
+ if (typeof model === 'string') return EMBEDDING_RE.test(model);
+ if (typeof model !== 'object') return false;
+ // LM Studio's native model list types every model (`embeddings` / `llm` /
+ // `vlm`); Ollama's /api/show reports a capabilities array. Either one is
+ // authoritative in BOTH directions, so a chat model whose NAME happens to
+ // match (a fine-tune with `e5` in it) is not hidden from a generation picker.
+ //
+ // BOTH spellings are accepted because two vocabularies reach here: Ollama's
+ // raw capability is `embedding`, while a normalized PortOS model card carries
+ // the BADGE label `embeddings` (`localLlm.js#OLLAMA_CAPABILITY_BADGES` /
+ // `lmStudioBadgeCapabilities`). Matching only one would make a non-empty
+ // badge array an authoritative FALSE for a model that is plainly an
+ // embedding model.
+ const type = model.type ? String(model.type).toLowerCase() : null;
+ if (isEmbeddingCapability(type)) return true;
+ if (Array.isArray(model.capabilities) && model.capabilities.length > 0) {
+ return model.capabilities.some((c) => isEmbeddingCapability(c));
+ }
+ if (type) return false; // explicit non-embedding type — don't regex-guess past it
+ const id = model.id || model.name || '';
return typeof id === 'string' && id.length > 0 && EMBEDDING_RE.test(id);
}
/**
* A model usable for chat/generation — anything that isn't an embedding model.
- * @param {string} id
+ * @param {string|{id?:string,name?:string,capabilities?:string[]}} model
* @returns {boolean}
*/
-export function isGenerationModel(id) {
- return typeof id === 'string' && id.length > 0 && !isEmbeddingModel(id);
+export function isGenerationModel(model) {
+ if (typeof model === 'string') return model.length > 0 && !isEmbeddingModel(model);
+ return Boolean(model && typeof model === 'object' && (model.id || model.name)) && !isEmbeddingModel(model);
}
// Vision / multimodal (VLM) model id markers. These are the families that
@@ -201,7 +244,7 @@ const EDITORIAL_FAMILY_RANK = [
// read images (Gemma 4, Qwen3.5, Ministral 3) are excellent editors, so the
// `-VL` / `…V` / OCR suffixes are matched rather than a whole family.
const NON_EDITORIAL_RE =
- /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5)(?:[-_/:]|$)|text-embedding|embeddinggemma|coder|code-|starcoder|codellama|codegemma|(?:^|[-_/:])vision(?:[-_/:]|$)|(?:^|[-_/:])vl(?:\d|[-_/:.]|$)|qwen[\d.]*-?vl|glm-?[\d.]+v(?:[-_/:.]|$)|(?:^|[-_/:])ocr(?:[-_/:.]|$)|llava|moondream|minicpm-v|whisper|(?:^|[-_/:])tts(?:[-_/:]|$)|stable-?diffusion|sdxl|flux/i;
+ /(?:^|[-_/:])(?:embed|embedding|bge|nomic|mxbai|gte|e5)(?:[-_/:]|$)|text-embedding|embeddinggemma|minilm|paraphrase-multilingual|coder|code-|starcoder|codellama|codegemma|(?:^|[-_/:])vision(?:[-_/:]|$)|(?:^|[-_/:])vl(?:\d|[-_/:.]|$)|qwen[\d.]*-?vl|glm-?[\d.]+v(?:[-_/:.]|$)|(?:^|[-_/:])ocr(?:[-_/:.]|$)|llava|moondream|minicpm-v|whisper|(?:^|[-_/:])tts(?:[-_/:]|$)|stable-?diffusion|sdxl|flux/i;
/** Parse a parameter count in billions from a model's `params`/id (e.g. "35B"). */
function parseParamsB(model) {
diff --git a/server/lib/localModelHeuristics.test.js b/server/lib/localModelHeuristics.test.js
index 184bd1c5c4..ee620cb086 100644
--- a/server/lib/localModelHeuristics.test.js
+++ b/server/lib/localModelHeuristics.test.js
@@ -83,6 +83,12 @@ describe('localModelHeuristics', () => {
// marker alone misses it — it must never be offered for generation.
'embeddinggemma:300m',
'lmstudio-community/embeddinggemma-300m-qat-GGUF',
+ // No `embed` marker anywhere in the id — matched by FAMILY, or the
+ // assessment sweep benchmarks it and Ollama answers every sample with
+ // `400 "all-minilm:latest" does not support chat`.
+ 'all-minilm:latest',
+ 'all-minilm:33m',
+ 'paraphrase-multilingual:latest',
]) {
expect(isEmbeddingModel(id), id).toBe(true);
}
@@ -105,12 +111,37 @@ describe('localModelHeuristics', () => {
expect(isEmbeddingModel(null)).toBe(false);
expect(isEmbeddingModel(undefined)).toBe(false);
expect(isEmbeddingModel('')).toBe(false);
+ expect(isEmbeddingModel(42)).toBe(false);
+ });
+
+ it('prefers backend capability metadata over the id, in both directions', () => {
+ // Ollama's /api/show reports `capabilities: ['embedding']`.
+ expect(isEmbeddingModel({ id: 'mystery-model:latest', capabilities: ['embedding'] })).toBe(true);
+ // A normalized PortOS model card carries the BADGE label instead
+ // (`localLlm.js#OLLAMA_CAPABILITY_BADGES` maps `embedding` → `embeddings`,
+ // and LM Studio cards always carry a non-empty badge array), so matching
+ // only the raw spelling would turn every such card into a false negative.
+ expect(isEmbeddingModel({ id: 'mystery-model:latest', capabilities: ['embeddings'] })).toBe(true);
+ expect(isEmbeddingModel({ id: 'all-minilm:latest', capabilities: ['chat'] })).toBe(false);
+ // A non-empty capabilities array WITHOUT `embedding` is an explicit
+ // negative — a chat model whose name happens to match must not be hidden.
+ expect(isEmbeddingModel({ id: 'all-minilm:latest', capabilities: ['completion'] })).toBe(false);
+ // LM Studio types every model instead of listing capabilities.
+ expect(isEmbeddingModel({ id: 'mystery', type: 'embeddings' })).toBe(true);
+ expect(isEmbeddingModel({ id: 'all-minilm', type: 'llm' })).toBe(false);
+ // No metadata at all → fall back to the id.
+ expect(isEmbeddingModel({ id: 'all-minilm:latest' })).toBe(true);
+ expect(isEmbeddingModel({ name: 'qwen3.6:35b' })).toBe(false);
});
it('isGenerationModel is the inverse for real ids', () => {
expect(isGenerationModel('qwen3.6:35b')).toBe(true);
expect(isGenerationModel('nomic-embed-text:latest')).toBe(false);
+ expect(isGenerationModel('all-minilm:latest')).toBe(false);
expect(isGenerationModel('')).toBe(false);
+ expect(isGenerationModel({ id: 'qwen3.6:35b' })).toBe(true);
+ expect(isGenerationModel({ id: 'all-minilm:latest', capabilities: ['embedding'] })).toBe(false);
+ expect(isGenerationModel(null)).toBe(false);
});
});
@@ -210,6 +241,18 @@ describe('localModelHeuristics', () => {
expect(rec?.id).toBe('llama3.2:latest');
});
+ it('never recommends an embedding model whose id carries no embed marker', () => {
+ // `all-minilm` / `paraphrase-multilingual` name no `embed` token at all;
+ // without the family markers they land in the candidate pool and win
+ // whenever nothing better is installed.
+ expect(recommendEditorialModel([{ id: 'all-minilm:latest' }])).toBeNull();
+ expect(recommendEditorialModel([{ id: 'paraphrase-multilingual:latest' }])).toBeNull();
+ expect(recommendEditorialModel([
+ { id: 'all-minilm:latest' },
+ { id: 'llama3.2:latest', params: '3.2B' },
+ ])?.id).toBe('llama3.2:latest');
+ });
+
it('skips code-specialized and vision models', () => {
const rec = recommendEditorialModel([
{ id: 'codellama:13b', params: '13B' },
diff --git a/server/services/localModelAssessmentSweep.js b/server/services/localModelAssessmentSweep.js
index 0510e394e7..02b57c0557 100644
--- a/server/services/localModelAssessmentSweep.js
+++ b/server/services/localModelAssessmentSweep.js
@@ -64,6 +64,7 @@
*/
import { selectSweepTargets, SWEEP_SCOPES } from '../lib/localModelAssessment.js';
+import { isEmbeddingModel } from '../lib/localModelHeuristics.js';
import { tuningGridFor } from '../lib/localModelTuning.js';
import {
captureLaunchState,
@@ -373,6 +374,12 @@ async function beginSweep({ scope, backend, modelId, tunings, contextTokens, onP
if (tunings && !isTuningSweepable(named.backend)) {
return { ...snapshot(), rejected: `PortOS cannot sweep ${named.backend} tunings yet — it has no way to put the runtime back afterwards` };
}
+ // A named embedding model would also produce an empty list (the selector drops
+ // it), and "not installed" would be a lie — it is installed, it just has no
+ // generation to measure. Say which it is.
+ if (named && isEmbeddingModel(named.modelId)) {
+ return { ...snapshot(), rejected: `${named.modelId} is an embedding model — it has no chat/generation to measure` };
+ }
const grid = named && tunings ? tuningGridFor(named.backend) : null;
// A runtime PortOS cannot pass flags to yields the baseline alone — one
// measurement with nothing to compare it to. Refuse rather than spend minutes
diff --git a/server/services/localModelAssessmentSweep.test.js b/server/services/localModelAssessmentSweep.test.js
index 7c7b8a35fe..9973ccee05 100644
--- a/server/services/localModelAssessmentSweep.test.js
+++ b/server/services/localModelAssessmentSweep.test.js
@@ -163,6 +163,33 @@ describe('startSweep', () => {
expect((await startSweep({ scope: 'unmeasured' })).status).toBe('running');
});
+ // Every sample of an embedding-only model comes back
+ // `400 "<model>" does not support chat`, so the selector drops it — which
+ // would leave a NAMED one looking un-installed. Say what is actually wrong.
+ it('refuses a named embedding model without calling it not installed', async () => {
+ getAssessmentReport.mockResolvedValue(report({
+ unassessed: [{ backend: 'ollama', modelId: 'all-minilm:latest' }],
+ }));
+ const result = await startSweep({ backend: 'ollama', modelId: 'all-minilm:latest' });
+ expect(result.rejected).toMatch(/embedding model/i);
+ expect(result.rejected).not.toMatch(/not installed/i);
+ expect(runAssessment).not.toHaveBeenCalled();
+ });
+
+ it('skips embedding models in a scope sweep and measures the rest', async () => {
+ getAssessmentReport.mockResolvedValue(report({
+ unassessed: [
+ { backend: 'ollama', modelId: 'all-minilm:latest' },
+ { backend: 'ollama', modelId: 'nomic-embed-text:latest' },
+ { backend: 'ollama', modelId: 'qwen3.6:35b' },
+ ],
+ }));
+ runAssessment.mockResolvedValue(measured());
+ await startSweep({ scope: 'unmeasured' });
+ await settle();
+ expect(runAssessment.mock.calls.map((c) => c[0].modelId)).toEqual(['qwen3.6:35b']);
+ });
+
it('refuses a scope that covers nothing', async () => {
getAssessmentReport.mockResolvedValue(report());
const result = await startSweep({ scope: 'all' });
diff --git a/server/services/localModelAssessments.js b/server/services/localModelAssessments.js
index 3c465cb125..a3a263b649 100644
--- a/server/services/localModelAssessments.js
+++ b/server/services/localModelAssessments.js
@@ -98,6 +98,7 @@ import {
import { getMtplxServerEndpoint, getMtplxServerStatus, relaunchMtplxServerWithTuning } from './mtplxServerManager.js';
import { getSpecDecodePresetStatus } from './specDecodeModels.js';
import { listModels } from './localLlm.js';
+import { isEmbeddingModel } from '../lib/localModelHeuristics.js';
import {
getLoadedModels as getLoadedOllamaModels,
getLastInstalledModelsError as getOllamaListError,
@@ -380,6 +381,18 @@ function describeVerdict(verdict, samples) {
* @returns {Promise<object>} the persisted assessment record
*/
export async function runAssessment({ backend, modelId, contextTokens = DEFAULT_CONTEXT_TOKENS, tuning, resetTuning = false, signal, onProgress, claimTimeoutMs = 0 } = {}) {
+ // Refused BEFORE the heavy-job claim and before any provider call: every
+ // sample of an embedding-only model comes back `400 "<model>" does not
+ // support chat`, and each one raises an AI-provider investigation task for a
+ // failure that is fully determined by the model id. `selectSweepTargets`
+ // already keeps these out of a sweep; this covers the direct
+ // `POST /api/local-llm/assessments/run` route, which never goes through it.
+ if (isEmbeddingModel(modelId)) {
+ throw new ServerError(
+ `${modelId} is an embedding model — it has no chat/generation to measure`,
+ { status: 400, code: 'MODEL_NOT_ASSESSABLE', context: { backend, modelId } },
+ );
+ }
const contexts = [...new Set(contextTokens)].filter((n) => Number.isFinite(n) && n > 0).sort((a, b) => a - b);
// The listener runs outside the request lifecycle's error path in some callers
// (a socket emit can throw on a closed io), and a broken progress consumer must
@@ -891,7 +904,13 @@ export async function getAssessmentReport({ intent = 'balanced' } = {}) {
// sweep scope — where the failed run also fires the provider-failure hook
// and files a CoS investigation about a model that was never going to
// generate text (run b361be1a, nomic-embed-text:latest).
- if (isEmbeddingModel(model?.id || '')) continue;
+ //
+ // The model CARD is passed, not the bare id, so a backend that reports
+ // what a model can do (Ollama capabilities, LM Studio types) decides it
+ // rather than the name heuristic — which is how `all-minilm:latest`, an
+ // embedding model naming no `embed` marker at all, got through the
+ // id-only form and burned a second measurement.
+ if (isEmbeddingModel(model)) continue;
if (model?.id && !assessedModels.has(assessmentKey(runtime, model.id))) {
unassessed.push({ backend: runtime, modelId: model.id, params: model.params ?? null });
}
diff --git a/server/services/localModelAssessments.test.js b/server/services/localModelAssessments.test.js
index cbbb25e8a8..aa9352c32b 100644
--- a/server/services/localModelAssessments.test.js
+++ b/server/services/localModelAssessments.test.js
@@ -233,6 +233,29 @@ describe('loadAssessments / getAssessmentReport (read path)', () => {
expect(report.unassessed).toContainEqual({ backend: 'ollama', modelId: 'example-model:7b', params: '7B' });
});
+ // An embedding model has no chat/generation to measure, so it is not an
+ // unanswered question — listing it here offered a Measure button that could
+ // only ever spend a provider call to prove it fails.
+ it('leaves embedding models out of the not-yet-measured list', async () => {
+ listModels.mockImplementation(async (backend) => (backend === 'ollama'
+ ? [{ id: 'example-model:7b', params: '7B' }, { id: 'all-minilm:latest' }, { id: 'nomic-embed-text:latest' }]
+ : []));
+ const report = await svc.getAssessmentReport();
+ expect(report.unassessed.map((u) => u.modelId)).toEqual(['example-model:7b']);
+ // ...and the consent gate's counts follow, since they derive from the same list.
+ expect(report.sweepScopes.unmeasured).toBe(1);
+ });
+
+ // The backend's own capability metadata outranks the name heuristic in both
+ // directions, so a chat model that merely LOOKS like an embedding one stays.
+ it('keeps a model the backend reports as chat-capable', async () => {
+ listModels.mockImplementation(async (backend) => (backend === 'ollama'
+ ? [{ id: 'all-minilm:latest', capabilities: ['completion'] }]
+ : []));
+ const report = await svc.getAssessmentReport();
+ expect(report.unassessed.map((u) => u.modelId)).toEqual(['all-minilm:latest']);
+ });
+
it('flags a backend whose model list could not be read, even though it returned []', async () => {
// Both managers cache an EMPTY list on a failed read instead of throwing, so
// the manager's own error getter is the only signal that separates "no
@@ -333,6 +356,34 @@ describe('runAssessment — machine-wide accelerator claim', () => {
});
});
+describe('runAssessment — embedding models are not assessable', () => {
+ // An assessment measures a model by GENERATING with it. Ollama answers every
+ // sample aimed at an embedding-only model with
+ // `400 "<model>" does not support chat`, so the run is doomed by the model id
+ // alone — and each doomed sample raised an AI-provider investigation task.
+ // `selectSweepTargets` keeps these out of a sweep; this covers the direct
+ // `POST /api/local-llm/assessments/run` route, which never goes through it.
+ it('refuses before claiming the machine or calling a provider', async () => {
+ runLocalLlmTest.mockResolvedValue(okRun());
+ await expect(svc.runAssessment({ backend: 'ollama', modelId: 'all-minilm:latest', contextTokens: [512] }))
+ .rejects.toMatchObject({ code: 'MODEL_NOT_ASSESSABLE', status: 400 });
+ expect(runLocalLlmTest).not.toHaveBeenCalled();
+ // Nothing recorded — a stored `incompatible` reading would read as "this
+ // machine cannot run it", which is not what happened.
+ expect(await svc.loadAssessments()).toEqual([]);
+ // ...and the machine claim was never taken, so the next job can start.
+ const after = await claimHeavyLocalJob({ kind: 'probe', id: 'after-embed' });
+ expect(after.ok).toBe(true);
+ await after.release();
+ });
+
+ it('still measures a generation model whose id merely looks unusual', async () => {
+ runLocalLlmTest.mockResolvedValue(okRun());
+ const result = await svc.runAssessment({ backend: 'ollama', modelId: 'example-model:7b', contextTokens: [512] });
+ expect(result.verdict).toBe('fits');
+ });
+});
+
describe('runAssessment', () => {
it('refuses an embedding-only model before claiming the machine', async () => {
// Reaching here means a direct API call or a stale page — the report already