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: report a local provider as not ready when its offered models are gone from the daemon (#6125)

Adam Eivy783b863aa3fc
diff --git a/server/lib/opencodeConfig.js b/server/lib/opencodeConfig.js
index d73988b7cf..b7375f07e7 100644
--- a/server/lib/opencodeConfig.js
+++ b/server/lib/opencodeConfig.js
@@ -16,6 +16,21 @@
* dynamically at spawn time, declaring the provider's configured models (+ the
* model being run) under
* `provider.<local-backend>.models` with bare ids.
+ *
+ * **The custom-provider shape above is still the supported one** — re-verified
+ * against OpenCode 1.18.27, where a config carrying the models map round-trips a
+ * local Ollama model fine. What CHANGED is the diagnostic: the same undeclared
+ * model that used to say "Model ollama/… is not valid" now fails as an opaque
+ *
+ * {"name":"UnknownError","data":{"message":"Unexpected server error…"}}
+ *
+ * so a config missing the map reads like a broken provider rather than a
+ * misconfigured one. It cost #6125 an investigation; do not re-derive it. Two
+ * OTHER failures land in the same "spawns, ~12s, no output" shape and are NOT
+ * this one — `model '<id>' not found` (the daemon no longer holds that model,
+ * which `services/providerReadiness.js` now reports up front) and
+ * `<id> does not support tools` (a non-tool-capable model, which the
+ * `_fetchOllamaToolCapableModels` refresh filters out of the provider's list).
*/
import {
diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.js
index a97f29fa8a..38eee1f07d 100644
--- a/server/services/providerReadiness.js
+++ b/server/services/providerReadiness.js
@@ -21,6 +21,9 @@
* already answering, which proves it another way)
* 2. server — the endpoint the provider points at answers `GET /v1/models`
* 3. model — the provider's default model is one the endpoint serves
+ * 4. catalog — every OTHER model the provider offers is one the endpoint
+ * serves, so a task or pipeline stage cannot pin an id that
+ * only fails once the agent has already spawned
*
* Checks are reported in fix order, each with what to do about it. Only
* local-daemon providers get a report at all (`localProviderRuntime.js` decides
@@ -164,18 +167,45 @@ function findCommandCached(command) {
}
/**
- * The model id the endpoint would be asked for: the provider's default with any
- * OpenCode `<namespace>/` prefix stripped, since that prefix addresses the
- * OpenCode provider entry and never reaches the daemon's own model list.
- * Returns null when the provider selects no specific model.
+ * One model id as the daemon's own listing spells it: trimmed, with any OpenCode
+ * `<namespace>/` prefix stripped, since that prefix addresses the OpenCode
+ * provider entry and never reaches the daemon's model list. `null` for anything
+ * that does not name a model (blank, non-string, or a "use the CLI's own
+ * default" sentinel).
*/
-export function servedModelId(provider, kind) {
- const model = provider?.defaultModel;
+function bareModelId(model, kind) {
if (typeof model !== 'string' || model.trim() === '' || isConfiguredDefaultModel(model)) return null;
const trimmed = model.trim();
return trimmed.startsWith(`${kind}/`) ? trimmed.slice(kind.length + 1) : trimmed;
}
+/**
+ * The model id the endpoint would be asked for — the provider's default.
+ * Returns null when the provider selects no specific model.
+ */
+export function servedModelId(provider, kind) {
+ return bareModelId(provider?.defaultModel, kind);
+}
+
+/**
+ * The model ids this provider OFFERS beyond its pinned default — the catalog a
+ * task or a pipeline stage picks a model out of.
+ *
+ * The pin is excluded because `modelCheck` already covers it; what is left is
+ * the part of the provider nothing was checking. A provider that pins NO model
+ * (the shipped OpenCode local wrappers all ship `defaultModel: null`) had no
+ * model check at all, so its whole catalog could name ids the daemon has not
+ * served since the day they were pulled — and every run dispatched onto one
+ * died at spawn with no output instead of failing resolution up front (#6125).
+ */
+function offeredModelIds(provider, kind) {
+ const pinned = servedModelId(provider, kind);
+ const ids = (Array.isArray(provider?.models) ? provider.models : [])
+ .map((model) => bareModelId(model, kind))
+ .filter((id) => id !== null && id !== pinned);
+ return [...new Set(ids)];
+}
+
/**
* The fix hint for a check the one-click setup button already covers.
*
@@ -265,28 +295,34 @@ function serverCheck(runtime, { installed, result, setup, weights = 'unknown' })
};
}
+/**
+ * The `detail`/`fixHint` a model-facing check reports when the endpoint never
+ * answered, or answered unreadably. Shared by both such checks so a listing
+ * PortOS could not read is reported as unknown, never as missing — the user
+ * chases the check that IS actionable.
+ */
+function unreadableListing(runtime, probeError, weights, setup) {
+ // A server that answered 401 IS responding — "until the server responds"
+ // would send the user to start a container that is already up, when the
+ // actual fix is to paste its key onto this provider.
+ const detail = probeError === 'authentication required'
+ ? `${runtime.label} refused the model listing without an API key — paste the server's key on this provider.`
+ : weightsDetail(runtime, weights) || 'Cannot be checked until the server responds.';
+ // An unservable cache is the ONE unknown here that has a fix: the download
+ // that makes a start possible at all.
+ const fixHint = weightsBlockStart(weights) ? setupHint(setup, 'provisions') : null;
+ return { detail, fixHint };
+}
+
/**
* The `model` check — does the running daemon serve what this provider asks
* for? This is the alias mismatch: `llama-server --alias dflash` against a
* provider pinned to `dspark` fails HERE rather than inside a dead agent run.
- *
- * `served` is null when the endpoint never answered (or answered unreadably),
- * which says nothing about the model — reported as unknown, never as missing,
- * so the user chases the check that IS actionable.
*/
function modelCheck(runtime, wanted, served, probeError = null, { weights = 'unknown', setup = null } = {}) {
const label = `Model \`${wanted}\` available`;
if (!Array.isArray(served)) {
- // A server that answered 401 IS responding — "until the server responds"
- // would send the user to start a container that is already up, when the
- // actual fix is to paste its key onto this provider.
- const detail = probeError === 'authentication required'
- ? `${runtime.label} refused the model listing without an API key — paste the server's key on this provider.`
- : weightsDetail(runtime, weights) || 'Cannot be checked until the server responds.';
- // An unservable cache is the ONE unknown here that has a fix: the download
- // that makes a start possible at all.
- const fixHint = weightsBlockStart(weights) ? setupHint(setup, 'provisions') : null;
- return { id: 'model', label, ok: null, detail, fixHint };
+ return { id: 'model', label, ok: null, ...unreadableListing(runtime, probeError, weights, setup) };
}
if (served.includes(wanted)) {
return { id: 'model', label, ok: true, detail: `${runtime.label} is serving \`${wanted}\`.`, fixHint: null };
@@ -328,6 +364,55 @@ function modelCheck(runtime, wanted, served, probeError = null, { weights = 'unk
};
}
+/**
+ * The `catalog` check — can this provider dispatch the models it OFFERS?
+ *
+ * `modelCheck` above validates the pin. This validates everything else in the
+ * provider's `models` list, which is what a task or a pipeline stage actually
+ * picks from. Without it a provider that pins nothing (every shipped OpenCode
+ * local wrapper) passed readiness while its whole catalog named ids the daemon
+ * stopped serving — a stage pinned to one spawned, produced no output, and died
+ * at spawn time rather than failing resolution up front (#6125).
+ *
+ * `servesOneModel` runtimes are graded leniently on purpose: llama.cpp, MTPLX,
+ * vLLM, SGLang and Slotstream run ONE checkpoint per process, so a catalog
+ * listing the other presets is normal configuration rather than rot. One
+ * servable id is all such a provider ever needs. A multi-model daemon (Ollama,
+ * LM Studio) serves everything it holds at once, so there any unservable id is
+ * a real pin waiting to fail.
+ */
+function catalogCheck(runtime, offered, served, probeError = null, { weights = 'unknown', setup = null, pinned = null } = {}) {
+ const label = `Offered models available (${offered.length})`;
+ if (!Array.isArray(served)) {
+ return { id: 'catalog', label, ok: null, ...unreadableListing(runtime, probeError, weights, setup) };
+ }
+ const unserved = offered.filter((id) => !served.includes(id));
+ const ok = runtime.servesOneModel ? unserved.length < offered.length : unserved.length === 0;
+ if (ok) {
+ const detail = unserved.length === 0
+ ? `${runtime.label} is serving every model this provider offers.`
+ : `${runtime.label} is serving ${offered.length - unserved.length} of them; it runs one model per process, so the rest are presets nothing was started under.`;
+ return { id: 'catalog', label, ok: true, detail, fixHint: null };
+ }
+ const listed = unserved.slice(0, 3).map((id) => `\`${id}\``).join(', ');
+ const more = unserved.length > 3 ? ` +${unserved.length - 3} more` : '';
+ // "every run fails" is only true when the pin cannot carry the provider
+ // either — otherwise the provider still runs, and only a stage that pinned one
+ // of these ids dies.
+ const nothingDispatchable = unserved.length === offered.length && !(pinned && served.includes(pinned));
+ const detail = nothingDispatchable
+ ? `${runtime.label} serves none of them (${listed}${more}), so every run dispatched onto this provider fails before producing output.`
+ : `${runtime.label} does not serve ${listed}${more}, so a task or stage pinned to one of those fails at spawn.`;
+ return {
+ id: 'catalog',
+ label,
+ ok: false,
+ detail,
+ fixHint: `Refresh this provider's models so it only offers ids the server serves${runtime.manageUrl ? ', or pull the missing ones from Models → LLMs.' : `. ${runtime.modelsHint}`}`,
+ unservedModels: unserved,
+ };
+}
+
/**
* The requirements checklist for one provider, or `null` when the provider does
* not depend on a local daemon.
@@ -386,6 +471,8 @@ export async function getProviderReadiness(provider, deps = {}) {
// `probeEndpoint` returns `models: null` on every unreachable path, so this
// needs no second reachability test.
if (wanted) checks.push(modelCheck(runtime, wanted, result.models, result.error, { weights, setup }));
+ const offered = offeredModelIds(provider, runtime.kind);
+ if (offered.length > 0) checks.push(catalogCheck(runtime, offered, result.models, result.error, { weights, setup, pinned: wanted }));
return {
kind: runtime.kind,
diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.js
index 6ebf30e912..757719884d 100644
--- a/server/services/providerReadiness.test.js
+++ b/server/services/providerReadiness.test.js
@@ -197,7 +197,7 @@ describe('getProviderReadiness', () => {
expect(checkById(readiness, 'model').ok).toBe(true);
});
- it('omits the model check when the provider pins no model', async () => {
+ it('omits both model checks when the provider pins and offers nothing', async () => {
const readiness = await getProviderReadiness(
{ id: 'opencode-ollama', command: 'opencode', ollamaBacked: true, defaultModel: null },
{ findCommand: () => '/usr/local/bin/ollama', probe: reachable(['llama3:8b']) },
@@ -206,6 +206,70 @@ describe('getProviderReadiness', () => {
expect(readiness.ready).toBe(true);
});
+ it('fails a pin-less provider whose whole offered catalog is gone from the daemon', async () => {
+ // #6125: the shipped OpenCode local wrappers pin no default, so readiness
+ // ran no model check at all and reported ready while every model the
+ // provider offered had been removed from the daemon — each run spawned,
+ // produced nothing, and died. The catalog is the pin a stage picks from.
+ const readiness = await getProviderReadiness(
+ {
+ id: 'opencode-ollama-tui',
+ command: 'opencode',
+ ollamaBacked: true,
+ defaultModel: null,
+ models: ['ollama/example-coder:30b', 'example-chat:12b'],
+ },
+ { findCommand: () => '/usr/local/bin/ollama', probe: reachable(['other-model:8b']) },
+ );
+ const catalog = checkById(readiness, 'catalog');
+ expect(catalog.ok).toBe(false);
+ expect(catalog.label).toBe('Offered models available (2)');
+ // Namespace-stripped, so the ids read as the daemon spells them.
+ expect(catalog.unservedModels).toEqual(['example-coder:30b', 'example-chat:12b']);
+ expect(catalog.detail).toContain('serves none of them');
+ expect(readiness.ready).toBe(false);
+ });
+
+ it('names only the offered models a multi-model daemon stopped serving', async () => {
+ const readiness = await getProviderReadiness(
+ {
+ id: 'opencode-ollama-tui',
+ command: 'opencode',
+ ollamaBacked: true,
+ defaultModel: 'example-chat:12b',
+ models: ['example-chat:12b', 'example-coder:30b'],
+ },
+ { findCommand: () => '/usr/local/bin/ollama', probe: reachable(['example-chat:12b']) },
+ );
+ // The pin is the `model` check's job; `catalog` covers what is left.
+ expect(checkById(readiness, 'model').ok).toBe(true);
+ const catalog = checkById(readiness, 'catalog');
+ expect(catalog.unservedModels).toEqual(['example-coder:30b']);
+ expect(catalog.detail).toContain('fails at spawn');
+ expect(readiness.ready).toBe(false);
+ });
+
+ it('accepts a one-model-per-process runtime that is running one of its presets', async () => {
+ // llama.cpp serves a single checkpoint per process, so the other presets in
+ // the catalog were never separate downloads — grading them as missing would
+ // send the user after weights they already have.
+ const readiness = await getProviderReadiness(
+ llamaProvider({ defaultModel: null, models: ['dflash', 'dspark'] }),
+ { findCommand: () => '/opt/homebrew/bin/llama-server', probe: reachable(['dflash']) },
+ );
+ expect(checkById(readiness, 'catalog').ok).toBe(true);
+ expect(readiness.ready).toBe(true);
+ });
+
+ it('leaves the catalog check unknown — never failed — while the server is down', async () => {
+ const readiness = await getProviderReadiness(
+ llamaProvider({ defaultModel: null, models: ['dflash', 'dspark'] }),
+ { findCommand: () => '/opt/homebrew/bin/llama-server', probe: unreachable() },
+ );
+ expect(checkById(readiness, 'catalog').ok).toBeNull();
+ expect(readiness.ready).toBe(false);
+ });
+
it('probes the endpoint the provider configures, not the canonical default', async () => {
const probed = [];
await getProviderReadiness(