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: require text-capable local reviewer models (#5642)

[._.]/ Adam Eivy5331693bfcf9
diff --git a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
index 1c352ca0fe..99a1d81a74 100644
--- a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
+++ b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
@@ -102,7 +102,7 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
effort={stageEffort}
onEffortChange={(effort) => updateStage('effort', effort)}
emptyProviderOption={isSecurityStage ? 'Select local provider (required)' : 'Default (task-level)'}
- emptyModelOption={isSecurityStage ? 'Select verified tool-free model (required)' : 'Default (task-level)'}
+ emptyModelOption={isSecurityStage ? 'Select verified local text model (required)' : 'Default (task-level)'}
alwaysShowModel
selectionPolicy={selectionPolicy}
disabled={updating}
@@ -111,7 +111,7 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
<p className="text-xs text-gray-500 mt-2">
{localModelsLoading
? 'Loading local model capability reports…'
- : 'Security Scan requires an explicit local model whose runtime reports no tool-calling capability. CLI/TUI agents and unknown capability states are not eligible.'}
+ : 'Security Scan requires an explicit local text model whose runtime reports no tool-calling capability. Embedding-only models, CLI/TUI agents, and unknown capability states are not eligible.'}
</p>
)}
</div>
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 7972f43d42..866e328b1d 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -41,7 +41,7 @@ grep -i "what you want to do" client/src/utils/README.md
| `urlNormalize` | `isUrl` detection, `normalizeUrl` (optional git/`requireDot` modes), `isHttpUrl` (explicit http(s) only — safe-href check), and `tiktokVideoId` / `tiktokEmbedSrc` (host-anchored TikTok video-id extraction + its Embed Player URL, so a reference embeds without loading TikTok's embed.js). |
| `platform` | `isMac` detection and `modKey` (⌘/Ctrl) for keyboard-shortcut display. |
| `navWorkingSet` | Recent/pinned nav persistence (`recordVisit`, `togglePin`, `isPinned`) plus `resolveRecentNavEntries` for mapping stored deep links back to their longest matching nav-manifest entry. Also `migrateLegacyNavPath(path, commands)` — maps a stored path onto the CURRENT path of the page that used to answer to it, driven by each command's own `previousPaths` (declared in `server/lib/navManifest.js` beside the page that moved, shipped whole in the palette manifest). A pin is a stored route path, so without it a moved page's pin stops matching the manifest and the sidebar row silently vanishes on update. |
-| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isLaunchableTuiProvider` — a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt; shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree — `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` (an OpenCode wrapper front-ending a hosted OpenAI-compatible gateway — `orcarouter`, `openrouter` — which inherits its API key at spawn time from the sibling API provider whose id equals the gateway id; reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. MIRROR of `server/lib/providerGateways.js`, which the browser cannot import; keep the three copies in lockstep), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). `TOOL_FREE_LOCAL_PROVIDER_IDS`, `isToolFreeLocalProvider`, `isToolFreeLocalModel`, and `toolFreeLocalSelectionPolicy` share the fail-closed local/no-tools filter used by security-sensitive provider/model/effort pickers. Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `credentialSource(provider)` plus `providerCardState(provider, { runtime, status, keySetFor, envVarSet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent / empty credential environment variable), or simply switched off? Reads the SERVER's `missingPrerequisites` (published per provider on `GET /api/providers` from `server/lib/providerPrerequisites.js`, and the same computation `getFallbackProvider` routes on) and adds the local-app runtime shape plus tri-state checks for stored, inherited, and process environment credentials. Unknown lookup values mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. `resolvesOutsidePortosPath(provider)` — does this provider resolve its binary somewhere the runtime probe never looked (an explicit path in `command`, or its own `PATH` in `envVars`)? Mirror of the same two guards in the server's `providerRuntimeKey`, and what keeps the card's badge from accusing a working provider the router happily routes. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. |
+| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isLaunchableTuiProvider` — a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt; shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree — `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` (an OpenCode wrapper front-ending a hosted OpenAI-compatible gateway — `orcarouter`, `openrouter` — which inherits its API key at spawn time from the sibling API provider whose id equals the gateway id; reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. MIRROR of `server/lib/providerGateways.js`, which the browser cannot import; keep the three copies in lockstep), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). `TOOL_FREE_LOCAL_PROVIDER_IDS`, `TOOL_FREE_LOCAL_TEXT_CAPABILITIES`, `isToolFreeLocalProvider`, `isToolFreeLocalModel`, and `toolFreeLocalSelectionPolicy` share the fail-closed local/text/no-tools filter used by security-sensitive provider/model/effort pickers. Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `credentialSource(provider)` plus `providerCardState(provider, { runtime, status, keySetFor, envVarSet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent / empty credential environment variable), or simply switched off? Reads the SERVER's `missingPrerequisites` (published per provider on `GET /api/providers` from `server/lib/providerPrerequisites.js`, and the same computation `getFallbackProvider` routes on) and adds the local-app runtime shape plus tri-state checks for stored, inherited, and process environment credentials. Unknown lookup values mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. `resolvesOutsidePortosPath(provider)` — does this provider resolve its binary somewhere the runtime probe never looked (an explicit path in `command`, or its own `PATH` in `envVars`)? Mirror of the same two guards in the server's `providerRuntimeKey`, and what keeps the card's badge from accusing a working provider the router happily routes. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. |
| `systemCapabilities` | Server-annotated hardware compatibility helpers: preserve model/provider choices when compatibility is unknown, and hide only entries whose `hardwareCompatibility.state` is definitively `unavailable`. |
| `layeredIntelligenceReasons` | Canonical gloss for the Layered Intelligence loop's run-outcome reason tokens, shared by the on-demand toast and the durable "Last run" line (`formatLiReason`, `liReasonTone`, `LI_NEUTRAL_REASONS`). |
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 569bea7932..d7b02c76b0 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -187,6 +187,7 @@ export const AGENT_HARNESS_PROVIDER_TYPES = Object.freeze([
// but the harness still has filesystem/process authority, so they do not belong
// in a tool-free security-review picker.
export const TOOL_FREE_LOCAL_PROVIDER_IDS = Object.freeze(['ollama', 'lmstudio']);
+export const TOOL_FREE_LOCAL_TEXT_CAPABILITIES = Object.freeze(['chat', 'completion']);
/**
* True only for PortOS's canonical local HTTP backends on this machine.
@@ -202,10 +203,10 @@ export const isToolFreeLocalProvider = (provider) =>
&& isLocalInstanceProvider(provider);
/**
- * Whether a local model has an authoritative, explicit capability report that
- * excludes native tool use. Unknown capability state is unsafe for a security
- * scan and therefore returns false rather than falling back to model-name
- * heuristics.
+ * Whether a local model has an authoritative, explicit text capability report
+ * that excludes native tool use. Embedding-only models cannot review a diff;
+ * unknown capability state is unsafe for a security scan and therefore returns
+ * false rather than falling back to model-name heuristics.
*
* `capabilitiesByBackend` is the shape returned by `useLocalModels`; object
* model entries are accepted too so callers with a richer model catalog can use
@@ -219,7 +220,9 @@ export const isToolFreeLocalModel = (model, provider, capabilitiesByBackend = {}
? model.capabilities
: capabilitiesByBackend?.[localBackendForProvider(provider)]?.[id];
if (!Array.isArray(reported)) return false;
- return !reported.some((capability) => String(capability).toLowerCase() === 'tools');
+ const normalized = reported.map((capability) => String(capability).toLowerCase());
+ return normalized.some((capability) => TOOL_FREE_LOCAL_TEXT_CAPABILITIES.includes(capability))
+ && !normalized.includes('tools');
};
/**
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index a4aee3c836..94fe7d0c05 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -909,10 +909,20 @@ describe('toolFreeLocalSelectionPolicy', () => {
expect(isToolFreeLocalProvider({ ...ollama, endpoint: 'http://example.internal:11434/v1' })).toBe(false);
});
- it('requires an authoritative capability report and rejects tool-capable models', () => {
- const capabilities = { ollama: { 'safe-model': ['chat'], 'agent-model': ['chat', 'tools'], 'empty-model': [] } };
+ it('requires an authoritative text capability report and rejects tool or embedding models', () => {
+ const capabilities = {
+ ollama: {
+ 'safe-model': ['chat'],
+ 'completion-model': ['completion'],
+ 'agent-model': ['chat', 'tools'],
+ 'embedding-model': ['embedding'],
+ 'empty-model': [],
+ },
+ };
expect(isToolFreeLocalModel('safe-model', ollama, capabilities)).toBe(true);
- expect(isToolFreeLocalModel('empty-model', ollama, capabilities)).toBe(true);
+ expect(isToolFreeLocalModel('completion-model', ollama, capabilities)).toBe(true);
+ expect(isToolFreeLocalModel('embedding-model', ollama, capabilities)).toBe(false);
+ expect(isToolFreeLocalModel('empty-model', ollama, capabilities)).toBe(false);
expect(isToolFreeLocalModel('agent-model', ollama, capabilities)).toBe(false);
expect(isToolFreeLocalModel('unknown-model', ollama, capabilities)).toBe(false);
expect(isToolFreeLocalModel({ id: 'safe-object', capabilities: ['chat'] }, ollama, {})).toBe(true);
diff --git a/server/services/prReviewerSecurity.js b/server/services/prReviewerSecurity.js
index f69b33767b..178cc543e2 100644
--- a/server/services/prReviewerSecurity.js
+++ b/server/services/prReviewerSecurity.js
@@ -25,6 +25,7 @@ export const TOOL_FREE_LOCAL_BACKENDS = Object.freeze([...LOCAL_LLM_REVIEWERS])
export const SECURITY_SCAN_MAX_OPEN_PRS = 200
export const SECURITY_SCAN_MAX_DIFF_CHARS = 500_000
export const SECURITY_SCAN_MAX_VERDICT_CHARS = 20_000
+const TOOL_FREE_LOCAL_TEXT_CAPABILITIES = new Set(['chat', 'completion'])
const failure = (code, extra = {}) => ({ ok: false, passed: false, code, ...extra })
@@ -39,6 +40,11 @@ const hasToolCapability = (capabilities) => (
&& capabilities.some((capability) => String(capability).toLowerCase() === 'tools')
)
+const hasTextCapability = (capabilities) => (
+ Array.isArray(capabilities)
+ && capabilities.some((capability) => TOOL_FREE_LOCAL_TEXT_CAPABILITIES.has(String(capability).toLowerCase()))
+)
+
/**
* True only for the two canonical, direct local HTTP providers. A renamed or
* remote provider is intentionally excluded even when its name mentions a
@@ -53,15 +59,16 @@ export function isToolFreeLocalProvider(provider) {
}
/**
- * Require an installed model with an explicit capability report that does not
- * list tools. `null`/missing capability metadata is unknown, not safe.
+ * Require an installed model with an explicit text capability report that does
+ * not list tools. Embedding-only models cannot review a diff, and `null`/missing
+ * capability metadata is unknown, not safe.
*/
export function isToolFreeLocalModel(model, provider, installedModels = []) {
if (!isToolFreeLocalProvider(provider)) return false
const id = modelId(model)
if (!id || !Array.isArray(installedModels)) return false
const installed = installedModels.find((entry) => modelId(entry) === id)
- return Array.isArray(installed?.capabilities) && !hasToolCapability(installed.capabilities)
+ return hasTextCapability(installed?.capabilities) && !hasToolCapability(installed.capabilities)
}
/**
diff --git a/server/services/prReviewerSecurity.test.js b/server/services/prReviewerSecurity.test.js
index 7e76b0e82f..a6726a90bb 100644
--- a/server/services/prReviewerSecurity.test.js
+++ b/server/services/prReviewerSecurity.test.js
@@ -73,10 +73,13 @@ describe('pr-reviewer Security Scan selection', () => {
expect(isToolFreeLocalProvider({ ...localProvider(), id: 'custom-ollama' })).toBe(false)
})
- it('requires an installed model with explicit capabilities and no tools', () => {
+ it('requires an installed text model with explicit capabilities and no tools', () => {
const provider = localProvider()
expect(isToolFreeLocalModel('safe-model', provider, [{ id: 'safe-model', capabilities: ['chat'] }])).toBe(true)
+ expect(isToolFreeLocalModel('completion-model', provider, [{ id: 'completion-model', capabilities: ['completion'] }])).toBe(true)
expect(isToolFreeLocalModel('tool-model', provider, [{ id: 'tool-model', capabilities: ['chat', 'tools'] }])).toBe(false)
+ expect(isToolFreeLocalModel('embedding-model', provider, [{ id: 'embedding-model', capabilities: ['embedding'] }])).toBe(false)
+ expect(isToolFreeLocalModel('empty-model', provider, [{ id: 'empty-model', capabilities: [] }])).toBe(false)
expect(isToolFreeLocalModel('unknown-model', provider, [{ id: 'unknown-model' }])).toBe(false)
expect(isToolFreeLocalModel('missing-model', provider, [])).toBe(false)
})
@@ -91,6 +94,11 @@ describe('pr-reviewer Security Scan selection', () => {
getModelCapabilitiesMock.mockResolvedValue(null)
await expect(resolveToolFreeLocalSecurityModel({ providerId: 'ollama', model: 'safe-model' }))
.resolves.toMatchObject({ ok: false, code: 'security-scan-model-not-verified' })
+
+ listModelsMock.mockResolvedValue([{ id: 'safe-model', capabilities: ['chat'] }])
+ getModelCapabilitiesMock.mockResolvedValue(['embedding'])
+ await expect(resolveToolFreeLocalSecurityModel({ providerId: 'ollama', model: 'safe-model' }))
+ .resolves.toMatchObject({ ok: false, code: 'security-scan-model-not-verified' })
})
})