Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(brain): ollama lists downloads only + capability-gated small default

Ruben Lütkecd243aea215a
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.py
index 2348ba5cad..a03d9a5f3d 100644
--- a/jarvis/brain/model_catalog.py
+++ b/jarvis/brain/model_catalog.py
@@ -24,6 +24,7 @@ frontier resolver's 24 h — fresher is better for a list the user browses), wit
special case: its public catalog changes daily, so its cache lifetime is capped
at five minutes even when the general TTL is longer.
"""
+
from __future__ import annotations
import asyncio
@@ -49,9 +50,13 @@ DEFAULT_TTL_HOURS = 6
# immediate fetch, and an explicitly shorter global TTL continues to win.
_PROVIDER_TTL_CAP_SECONDS: dict[str, float] = {
"openrouter": 5 * 60,
+ # Local servers: the installed model set changes with every `ollama pull` /
+ # server restart, and the fetch is a LAN round-trip — keep it near-live.
+ "ollama": 60,
+ "local-openai": 60,
}
-# The API-key brain providers whose catalogs we can enumerate. Codex is excluded
+# The brain providers whose catalogs we can enumerate. Codex is excluded
# on purpose: it authenticates via the ChatGPT login / a generic OpenAI key and
# its model id is largely ignored by the ``codex exec`` CLI path — it has no own
# model picker in the UI (it renders the Codex login widget instead).
@@ -62,30 +67,78 @@ CATALOG_PROVIDERS: tuple[str, ...] = (
"openrouter",
"grok",
"nvidia",
+ # Keyless local providers (2026-07-25): their "catalog" is the live list of
+ # models the user's own server holds — ollama via the native /api/tags,
+ # local-openai via the standard /v1/models.
+ "ollama",
+ "local-openai",
)
-# Endpoint + auth shape per provider. ``auth`` selects how the key is attached:
-# "x-api-key" → Anthropic header pair
-# "bearer" → Authorization: Bearer (OpenAI-compatible: OpenAI, Grok)
-# "query" → ?key= (Gemini)
-# "bearer_opt" → Authorization: Bearer if a key exists, else anonymous
-# (OpenRouter's catalog is public)
-_ENDPOINTS: dict[str, tuple[str, str]] = {
- "claude-api": ("https://api.anthropic.com/v1/models", "x-api-key"),
- "openai": ("https://api.openai.com/v1/models", "bearer"),
- "gemini": (
- "https://generativelanguage.googleapis.com/v1beta/models",
+
+@dataclass(frozen=True, slots=True)
+class _CatalogEndpoint:
+ """Catalog wiring for one provider.
+
+ ``vendor_base`` is the provider's default base in the SAME convention its
+ brain plugin uses for ``[brain.providers.<id>].base_url`` overrides (with
+ or without ``/v1``, or a bare server root for the local providers), so an
+ override composes with ``path`` exactly like the vendor default does.
+ ``None`` = no vendor default: without a configured override the fetch
+ raises an honest error (local-openai) or resolves dynamically (ollama's
+ OLLAMA_HOST handling). ``auth`` selects how the key is attached:
+
+ "x-api-key" → Anthropic header pair (key required)
+ "bearer" → Authorization: Bearer (key required)
+ "query" → ?key= (Gemini; key required)
+ "bearer_opt" → Authorization: Bearer if a key exists, else anonymous
+ (public catalogs: OpenRouter, NVIDIA NIM)
+ "none" → keyless local server; the optional ``secret_slot``
+ (keyring name, ENV name) is attached as Bearer when set.
+ """
+
+ vendor_base: str | None
+ path: str
+ auth: str
+ secret_slot: tuple[str, str] | None = None
+
+
+# Every fetch resolves the provider's EFFECTIVE base URL through
+# ``cfg.resolve_provider_endpoint`` (team proxy → base_url override → the
+# vendor default here) and appends ``path``. With no override configured the
+# resulting URLs are byte-identical to the former static table — pinned by
+# tests/unit/brain/test_model_catalog_local.py (S3a regression gate).
+_ENDPOINTS: dict[str, _CatalogEndpoint] = {
+ # Anthropic SDK convention: override EXCLUDES /v1 (the SDK appends it).
+ "claude-api": _CatalogEndpoint("https://api.anthropic.com", "/v1/models", "x-api-key"),
+ # OpenAI-compatible convention: override INCLUDES /v1.
+ "openai": _CatalogEndpoint("https://api.openai.com/v1", "/models", "bearer"),
+ # google-genai convention: override is the raw host (SDK appends /v1beta).
+ "gemini": _CatalogEndpoint(
+ "https://generativelanguage.googleapis.com",
+ "/v1beta/models",
"query",
),
- "openrouter": ("https://openrouter.ai/api/v1/models", "bearer_opt"),
+ "openrouter": _CatalogEndpoint("https://openrouter.ai/api/v1", "/models", "bearer_opt"),
# xAI uses the OpenAI-compatible ``data[].id`` model roster and requires
# the same bearer key used for Grok inference.
- "grok": ("https://api.x.ai/v1/models", "bearer"),
+ "grok": _CatalogEndpoint("https://api.x.ai/v1", "/models", "bearer"),
# NVIDIA NIM speaks the OpenAI-compatible ``data[].id`` shape. Its catalog is
# PUBLIC (verified 2026-07-08: an unauthenticated GET returns the full model
# list), so ``bearer_opt`` like OpenRouter — the picker fills in before a key
# is entered, and the key is attached when present.
- "nvidia": ("https://integrate.api.nvidia.com/v1/models", "bearer_opt"),
+ "nvidia": _CatalogEndpoint("https://integrate.api.nvidia.com/v1", "/models", "bearer_opt"),
+ # Ollama: server-root convention (the plugin appends /v1 / /api itself);
+ # vendor default resolves dynamically (OLLAMA_HOST → localhost:11434).
+ "ollama": _CatalogEndpoint(None, "/api/tags", "none"),
+ # Generic local OpenAI-compatible server: no default port is guessable
+ # (transformers serve 8000, llama-server 8080, LM Studio 1234) — the user
+ # sets the base URL on the card; without it the picker stays honestly empty.
+ "local-openai": _CatalogEndpoint(
+ None,
+ "/v1/models",
+ "none",
+ secret_slot=("local_openai_api_key", "LOCAL_OPENAI_API_KEY"),
+ ),
}
@@ -126,70 +179,82 @@ def _curated(pairs: list[tuple[str, str]]) -> list[ModelInfo]:
# offer a years-old model); when a valid key exists the live catalog supersedes
# this entirely, so a new release still shows up automatically there.
CURATED_MODELS: dict[str, list[ModelInfo]] = {
- "claude-api": _curated([
- ("claude-fable-5", "Claude Fable 5"),
- ("claude-opus-4-8", "Claude Opus 4.8"),
- ("claude-sonnet-5", "Claude Sonnet 5"),
- ("claude-haiku-4-5-20251001", "Claude Haiku 4.5"),
- ]),
- "openai": _curated([
- ("gpt-5.6-sol", "GPT-5.6 Sol (preview)"),
- ("gpt-5.6-terra", "GPT-5.6 Terra (preview)"),
- ("gpt-5.6-luna", "GPT-5.6 Luna (preview)"),
- ("gpt-5.6", "GPT-5.6 (Sol alias, preview)"),
- ("gpt-5.5", "GPT-5.5"),
- ("gpt-5.5-pro", "GPT-5.5 Pro"),
- ("gpt-5.4", "GPT-5.4"),
- ("gpt-5.4-pro", "GPT-5.4 Pro"),
- ("gpt-5.4-mini", "GPT-5.4 Mini"),
- ("gpt-5.4-nano", "GPT-5.4 Nano"),
- ]),
- "gemini": _curated([
- ("gemini-3.5-flash", "Gemini 3.5 Flash"),
- ("gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
- ("gemini-3-flash-preview", "Gemini 3 Flash"),
- ("gemini-3.1-flash-lite", "Gemini 3.1 Flash-Lite"),
- ("gemini-2.5-pro", "Gemini 2.5 Pro"),
- ("gemini-2.5-flash", "Gemini 2.5 Flash"),
- ("gemini-flash-lite-latest", "Gemini Flash Lite"),
- ]),
- "openrouter": _curated([
- ("anthropic/claude-fable-5", "Claude Fable 5"),
- ("anthropic/claude-opus-4.8", "Claude Opus 4.8"),
- ("anthropic/claude-sonnet-5", "Claude Sonnet 5"),
- ("anthropic/claude-haiku-4.5", "Claude Haiku 4.5"),
- ("openai/gpt-5.6-sol-pro", "GPT-5.6 Sol Pro"),
- ("openai/gpt-5.6-sol", "GPT-5.6 Sol"),
- ("openai/gpt-5.6-terra-pro", "GPT-5.6 Terra Pro"),
- ("openai/gpt-5.6-terra", "GPT-5.6 Terra"),
- ("openai/gpt-5.6-luna-pro", "GPT-5.6 Luna Pro"),
- ("openai/gpt-5.6-luna", "GPT-5.6 Luna"),
- ("google/gemini-3.5-flash", "Gemini 3.5 Flash"),
- ("google/gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
- ("x-ai/grok-4.20", "Grok 4.20"),
- ("deepseek/deepseek-v4-pro", "DeepSeek V4 Pro"),
- ]),
+ "claude-api": _curated(
+ [
+ ("claude-fable-5", "Claude Fable 5"),
+ ("claude-opus-4-8", "Claude Opus 4.8"),
+ ("claude-sonnet-5", "Claude Sonnet 5"),
+ ("claude-haiku-4-5-20251001", "Claude Haiku 4.5"),
+ ]
+ ),
+ "openai": _curated(
+ [
+ ("gpt-5.6-sol", "GPT-5.6 Sol (preview)"),
+ ("gpt-5.6-terra", "GPT-5.6 Terra (preview)"),
+ ("gpt-5.6-luna", "GPT-5.6 Luna (preview)"),
+ ("gpt-5.6", "GPT-5.6 (Sol alias, preview)"),
+ ("gpt-5.5", "GPT-5.5"),
+ ("gpt-5.5-pro", "GPT-5.5 Pro"),
+ ("gpt-5.4", "GPT-5.4"),
+ ("gpt-5.4-pro", "GPT-5.4 Pro"),
+ ("gpt-5.4-mini", "GPT-5.4 Mini"),
+ ("gpt-5.4-nano", "GPT-5.4 Nano"),
+ ]
+ ),
+ "gemini": _curated(
+ [
+ ("gemini-3.5-flash", "Gemini 3.5 Flash"),
+ ("gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
+ ("gemini-3-flash-preview", "Gemini 3 Flash"),
+ ("gemini-3.1-flash-lite", "Gemini 3.1 Flash-Lite"),
+ ("gemini-2.5-pro", "Gemini 2.5 Pro"),
+ ("gemini-2.5-flash", "Gemini 2.5 Flash"),
+ ("gemini-flash-lite-latest", "Gemini Flash Lite"),
+ ]
+ ),
+ "openrouter": _curated(
+ [
+ ("anthropic/claude-fable-5", "Claude Fable 5"),
+ ("anthropic/claude-opus-4.8", "Claude Opus 4.8"),
+ ("anthropic/claude-sonnet-5", "Claude Sonnet 5"),
+ ("anthropic/claude-haiku-4.5", "Claude Haiku 4.5"),
+ ("openai/gpt-5.6-sol-pro", "GPT-5.6 Sol Pro"),
+ ("openai/gpt-5.6-sol", "GPT-5.6 Sol"),
+ ("openai/gpt-5.6-terra-pro", "GPT-5.6 Terra Pro"),
+ ("openai/gpt-5.6-terra", "GPT-5.6 Terra"),
+ ("openai/gpt-5.6-luna-pro", "GPT-5.6 Luna Pro"),
+ ("openai/gpt-5.6-luna", "GPT-5.6 Luna"),
+ ("google/gemini-3.5-flash", "Gemini 3.5 Flash"),
+ ("google/gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
+ ("x-ai/grok-4.20", "Grok 4.20"),
+ ("deepseek/deepseek-v4-pro", "DeepSeek V4 Pro"),
+ ]
+ ),
# Grok 4.3 is the universal default because Grok 4.5 is not yet available
# in every region. The authenticated live catalog replaces this fallback.
- "grok": _curated([
- ("grok-4.3", "Grok 4.3"),
- ("grok-4.5", "Grok 4.5"),
- ]),
+ "grok": _curated(
+ [
+ ("grok-4.3", "Grok 4.3"),
+ ("grok-4.5", "Grok 4.5"),
+ ]
+ ),
# NVIDIA NIM — the offline fallback when the live /v1/models catalog is
# unreachable. NVIDIA-hosted current families (Nemotron leads: it is NVIDIA's
# own). A valid key supersedes this with the live list, so a newly hosted
# model still shows up automatically.
- "nvidia": _curated([
- ("nvidia/llama-3.1-nemotron-ultra-253b-v1", "Nemotron Ultra 253B"),
- ("nvidia/llama-3.3-nemotron-super-49b-v1.5", "Nemotron Super 49B v1.5"),
- ("deepseek-ai/deepseek-v4-pro", "DeepSeek V4 Pro"),
- ("deepseek-ai/deepseek-v4-flash", "DeepSeek V4 Flash"),
- ("moonshotai/kimi-k2.6", "Kimi K2.6"),
- ("z-ai/glm-5.2", "GLM-5.2"),
- ("qwen/qwen3.5-397b-a17b", "Qwen3.5 397B A17B"),
- ("meta/llama-4-maverick-17b-128e-instruct", "Llama 4 Maverick"),
- ("mistralai/mistral-large-3-675b-instruct-2512", "Mistral Large 3"),
- ]),
+ "nvidia": _curated(
+ [
+ ("nvidia/llama-3.1-nemotron-ultra-253b-v1", "Nemotron Ultra 253B"),
+ ("nvidia/llama-3.3-nemotron-super-49b-v1.5", "Nemotron Super 49B v1.5"),
+ ("deepseek-ai/deepseek-v4-pro", "DeepSeek V4 Pro"),
+ ("deepseek-ai/deepseek-v4-flash", "DeepSeek V4 Flash"),
+ ("moonshotai/kimi-k2.6", "Kimi K2.6"),
+ ("z-ai/glm-5.2", "GLM-5.2"),
+ ("qwen/qwen3.5-397b-a17b", "Qwen3.5 397B A17B"),
+ ("meta/llama-4-maverick-17b-128e-instruct", "Llama 4 Maverick"),
+ ("mistralai/mistral-large-3-675b-instruct-2512", "Mistral Large 3"),
+ ]
+ ),
}
@@ -222,48 +287,146 @@ TTS_CATALOG: dict[str, tuple[str, list[ModelInfo]]] = {
# Inworld — the new premium default (arena-#1 realtime, mid-2026). Voices are
# multilingual; these native masculine de/en/es voices are the curated pick,
# kept in sync with DEFAULT_VOICE_* in jarvis/plugins/tts/inworld_tts.py.
- "inworld": ("voice", _curated([
- ("Josef", "Josef — German, calm assistant (default)"),
- ("Johanna", "Johanna — German, warm"),
- ("Dennis", "Dennis — English, deep narrator"),
- ("Ashley", "Ashley — English, bright"),
- ("Diego", "Diego — Spanish, formal"),
- ("Lupita", "Lupita — Spanish, warm"),
- ])),
- "elevenlabs": ("voice", _curated([
- ("onwK4e9ZLuTAKqWW03F9", "Daniel — British, authoritative (default)"),
- ("JBFqnCBsd6RMkjVDRZzb", "George — British, deep narrator"),
- ("IKne3meq5aSn9XLyUdCD", "Charlie — British, mature butler"),
- ("nPczCjzI2devNBz1zQrb", "Brian — American, deep narrator"),
- ("pNInz6obpgDQGcFmaJgB", "Adam — American, classic AI voice"),
- ])),
- "gemini-flash-tts": ("voice", _ids([
- "Charon", "Kore", "Orus", "Iapetus", "Rasalgethi", "Algenib",
- "Algieba", "Fenrir", "Aoede", "Zephyr", "Puck", "Leda",
- "Callirrhoe", "Autonoe", "Enceladus", "Umbriel", "Despina",
- "Erinome", "Laomedeia", "Achernar", "Alnilam", "Schedar",
- "Gacrux", "Pulcherrima", "Achird", "Zubenelgenubi", "Vindemiatrix",
- "Sadachbia", "Sadaltager", "Sulafat",
- ])),
- "grok-voice": ("voice", _ids([
- "leo", "rex", "sal", "ara", "eve", "carina", "zagan", "helix",
- "orion", "luna", "iris", "altair", "zenith", "perseus", "helios",
- "lux", "kepler", "rigel", "cosmo", "celeste", "ursa", "sirius",
- "lumen", "castor", "naksh", "atlas",
- ])),
- "openai-tts": ("voice", _ids([
- "alloy", "ash", "ballad", "coral", "echo",
- "fable", "onyx", "nova", "sage", "shimmer", "verse", "marin", "cedar",
- ])),
- "google-neural2": ("voice", _ids([
- "en-US-Neural2-A", "en-US-Neural2-C", "en-US-Neural2-D", "en-US-Neural2-F",
- "de-DE-Neural2-B", "de-DE-Neural2-C", "de-DE-Neural2-D", "de-DE-Neural2-F",
- ])),
- "cartesia": ("model", _curated([
- ("sonic-3.5", "Sonic 3.5 (stable)"),
- ("sonic-3", "Sonic 3"),
- ("sonic-3-latest", "Sonic 3 latest (preview track)"),
- ])),
+ "inworld": (
+ "voice",
+ _curated(
+ [
+ ("Josef", "Josef — German, calm assistant (default)"),
+ ("Johanna", "Johanna — German, warm"),
+ ("Dennis", "Dennis — English, deep narrator"),
+ ("Ashley", "Ashley — English, bright"),
+ ("Diego", "Diego — Spanish, formal"),
+ ("Lupita", "Lupita — Spanish, warm"),
+ ]
+ ),
+ ),
+ "elevenlabs": (
+ "voice",
+ _curated(
+ [
+ ("onwK4e9ZLuTAKqWW03F9", "Daniel — British, authoritative (default)"),
+ ("JBFqnCBsd6RMkjVDRZzb", "George — British, deep narrator"),
+ ("IKne3meq5aSn9XLyUdCD", "Charlie — British, mature butler"),
+ ("nPczCjzI2devNBz1zQrb", "Brian — American, deep narrator"),
+ ("pNInz6obpgDQGcFmaJgB", "Adam — American, classic AI voice"),
+ ]
+ ),
+ ),
+ "gemini-flash-tts": (
+ "voice",
+ _ids(
+ [
+ "Charon",
+ "Kore",
+ "Orus",
+ "Iapetus",
+ "Rasalgethi",
+ "Algenib",
+ "Algieba",
+ "Fenrir",
+ "Aoede",
+ "Zephyr",
+ "Puck",
+ "Leda",
+ "Callirrhoe",
+ "Autonoe",
+ "Enceladus",
+ "Umbriel",
+ "Despina",
+ "Erinome",
+ "Laomedeia",
+ "Achernar",
+ "Alnilam",
+ "Schedar",
+ "Gacrux",
+ "Pulcherrima",
+ "Achird",
+ "Zubenelgenubi",
+ "Vindemiatrix",
+ "Sadachbia",
+ "Sadaltager",
+ "Sulafat",
+ ]
+ ),
+ ),
+ "grok-voice": (
+ "voice",
+ _ids(
+ [
+ "leo",
+ "rex",
+ "sal",
+ "ara",
+ "eve",
+ "carina",
+ "zagan",
+ "helix",
+ "orion",
+ "luna",
+ "iris",
+ "altair",
+ "zenith",
+ "perseus",
+ "helios",
+ "lux",
+ "kepler",
+ "rigel",
+ "cosmo",
+ "celeste",
+ "ursa",
+ "sirius",
+ "lumen",
+ "castor",
+ "naksh",
+ "atlas",
+ ]
+ ),
+ ),
+ "openai-tts": (
+ "voice",
+ _ids(
+ [
+ "alloy",
+ "ash",
+ "ballad",
+ "coral",
+ "echo",
+ "fable",
+ "onyx",
+ "nova",
+ "sage",
+ "shimmer",
+ "verse",
+ "marin",
+ "cedar",
+ ]
+ ),
+ ),
+ "google-neural2": (
+ "voice",
+ _ids(
+ [
+ "en-US-Neural2-A",
+ "en-US-Neural2-C",
+ "en-US-Neural2-D",
+ "en-US-Neural2-F",
+ "de-DE-Neural2-B",
+ "de-DE-Neural2-C",
+ "de-DE-Neural2-D",
+ "de-DE-Neural2-F",
+ ]
+ ),
+ ),
+ "cartesia": (
+ "model",
+ _curated(
+ [
+ ("sonic-3.5", "Sonic 3.5 (stable)"),
+ ("sonic-3", "Sonic 3"),
+ ("sonic-3-latest", "Sonic 3 latest (preview track)"),
+ ]
+ ),
+ ),
# OpenRouter TTS (the last-resort gateway) — the model picker offers ONLY the
# four allowlisted, production-grade speech models. The five open-source slop
# models (Kokoro, Orpheus, CSM-1B, both Zonos) are UNLISTED per the hard
@@ -271,12 +434,17 @@ TTS_CATALOG: dict[str, tuple[str, list[ModelInfo]]] = {
# multilingual bar on de/es coverage, beta stability, or GPU dependence. Every
# id here must satisfy curated_catalog.is_allowed("openrouter", id) — guarded
# by tests/unit/plugins/tts/test_openrouter_curation.py.
- "openrouter-tts": ("model", _ids([
- "google/gemini-3.1-flash-tts-preview",
- "x-ai/grok-voice-tts-1.0",
- "microsoft/mai-voice-2",
- "mistralai/voxtral-mini-tts-2603",
- ])),
+ "openrouter-tts": (
+ "model",
+ _ids(
+ [
+ "google/gemini-3.1-flash-tts-preview",
+ "x-ai/grok-voice-tts-1.0",
+ "microsoft/mai-voice-2",
+ "mistralai/voxtral-mini-tts-2603",
+ ]
+ ),
+ ),
}
# Realtime catalogs — REALTIME_MODELS + REALTIME_VOICES, keyed by realtime
@@ -301,31 +469,35 @@ TTS_CATALOG: dict[str, tuple[str, list[ModelInfo]]] = {
# they target dedicated translation/transcription sessions, not the general
# duplex voice-agent protocol implemented by this adapter.
REALTIME_MODELS: dict[str, list[ModelInfo]] = {
- "openai-realtime": _curated([
- ("gpt-realtime", "GPT Realtime (default)"),
- ("gpt-realtime-2.1", "GPT Realtime 2.1"),
- ("gpt-realtime-2.1-mini", "GPT Realtime 2.1 Mini"),
- ("gpt-realtime-2", "GPT Realtime 2"),
- ("gpt-realtime-1.5", "GPT Realtime 1.5"),
- ("gpt-realtime-mini", "GPT Realtime Mini"),
- ]),
+ "openai-realtime": _curated(
+ [
+ ("gpt-realtime", "GPT Realtime (default)"),
+ ("gpt-realtime-2.1", "GPT Realtime 2.1"),
+ ("gpt-realtime-2.1-mini", "GPT Realtime 2.1 Mini"),
+ ("gpt-realtime-2", "GPT Realtime 2"),
+ ("gpt-realtime-1.5", "GPT Realtime 1.5"),
+ ("gpt-realtime-mini", "GPT Realtime Mini"),
+ ]
+ ),
# gemini-live — verified 2026-07-10 against ai.google.dev/gemini-api/docs/models
# (the Live API model list). ``gemini-3.1-flash-live-preview`` is the current
# flagship (matches ``_MODEL`` in ``jarvis/plugins/realtime/gemini_live.py``);
# ``gemini-2.5-flash-native-audio-preview-12-2025`` is the current 2.5-series
# native-audio sibling still listed on that page. The older
# ``gemini-2.0-flash-live-preview`` family is marked for shutdown — omitted.
- "gemini-live": _curated([
- ("gemini-3.1-flash-live-preview", "Gemini 3.1 Flash Live (default)"),
- (
- "gemini-2.5-flash-native-audio-latest",
- "Gemini 2.5 Flash Native Audio (latest alias)",
- ),
- (
- "gemini-2.5-flash-native-audio-preview-12-2025",
- "Gemini 2.5 Flash Native Audio",
- ),
- ]),
+ "gemini-live": _curated(
+ [
+ ("gemini-3.1-flash-live-preview", "Gemini 3.1 Flash Live (default)"),
+ (
+ "gemini-2.5-flash-native-audio-latest",
+ "Gemini 2.5 Flash Native Audio (latest alias)",
+ ),
+ (
+ "gemini-2.5-flash-native-audio-preview-12-2025",
+ "Gemini 2.5 Flash Native Audio",
+ ),
+ ]
+ ),
# grok-realtime (xAI Voice Agent API) was REMOVED 2026-07-16: the xAI
# server drops the session contract after any response cancel, ignores
# the configured VAD silence window, swallows response.done, and spams
@@ -339,17 +511,54 @@ REALTIME_MODELS: dict[str, list[ModelInfo]] = {
# gemini-live: verified 2026-07-10 against the Live API capabilities guide,
# which now permits the complete 30-voice Gemini prebuilt roster.
REALTIME_VOICES: dict[str, list[ModelInfo]] = {
- "openai-realtime": _ids([
- "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse",
- "marin", "cedar",
- ]),
- "gemini-live": _ids([
- "Puck", "Charon", "Kore", "Fenrir", "Aoede", "Orus", "Leda", "Zephyr",
- "Callirrhoe", "Autonoe", "Enceladus", "Iapetus", "Umbriel", "Algieba",
- "Despina", "Erinome", "Algenib", "Rasalgethi", "Laomedeia", "Achernar",
- "Alnilam", "Schedar", "Gacrux", "Pulcherrima", "Achird", "Zubenelgenubi",
- "Vindemiatrix", "Sadachbia", "Sadaltager", "Sulafat",
- ]),
+ "openai-realtime": _ids(
+ [
+ "alloy",
+ "ash",
+ "ballad",
+ "coral",
+ "echo",
+ "sage",
+ "shimmer",
+ "verse",
+ "marin",
+ "cedar",
+ ]
+ ),
+ "gemini-live": _ids(
+ [
+ "Puck",
+ "Charon",
+ "Kore",
+ "Fenrir",
+ "Aoede",
+ "Orus",
+ "Leda",
+ "Zephyr",
+ "Callirrhoe",
+ "Autonoe",
+ "Enceladus",
+ "Iapetus",
+ "Umbriel",
+ "Algieba",
+ "Despina",
+ "Erinome",
+ "Algenib",
+ "Rasalgethi",
+ "Laomedeia",
+ "Achernar",
+ "Alnilam",
+ "Schedar",
+ "Gacrux",
+ "Pulcherrima",
+ "Achird",
+ "Zubenelgenubi",
+ "Vindemiatrix",
+ "Sadachbia",
+ "Sadaltager",
+ "Sulafat",
+ ]
+ ),
# Live roster verified through xAI's authenticated /v1/tts/voices endpoint.
# Eve leads because it is xAI's current Voice Agent default.
}
@@ -362,30 +571,34 @@ STT_CATALOG: dict[str, list[ModelInfo]] = {
# v1.0.1 — see the note in provider_spec.py. The wake-word local Whisper and
# the key-free STT fallback do NOT use this catalog (they read [stt].wake_*
# / construct FasterWhisperProvider directly), so no wake/fallback breakage.
- "openai-api": _ids([
- "gpt-4o-transcribe",
- "gpt-4o-mini-transcribe",
- "gpt-4o-mini-transcribe-2025-12-15",
- "gpt-4o-transcribe-diarize",
- "whisper-1",
- ]),
+ "openai-api": _ids(
+ [
+ "gpt-4o-transcribe",
+ "gpt-4o-mini-transcribe",
+ "gpt-4o-mini-transcribe-2025-12-15",
+ "gpt-4o-transcribe-diarize",
+ "whisper-1",
+ ]
+ ),
"deepgram": _ids(["nova-3", "nova-2", "nova-2-general", "enhanced", "base"]),
# OpenRouter STT — the model picker offers ONLY transcription models. This
# curated snapshot mirrors the live `?output_modalities=transcription` list
# (verified 2026-07-02); audio-in chat models are excluded. The default
# model (openai/whisper-large-v3) is listed first.
- "openrouter-stt": _ids([
- "openai/whisper-large-v3",
- "openai/gpt-4o-transcribe",
- "openai/gpt-4o-mini-transcribe",
- "openai/whisper-1",
- "openai/whisper-large-v3-turbo",
- "google/chirp-3",
- "mistralai/voxtral-mini-transcribe",
- "qwen/qwen3-asr-flash-2026-02-10",
- "nvidia/parakeet-tdt-0.6b-v3",
- "microsoft/mai-transcribe-1.5",
- ]),
+ "openrouter-stt": _ids(
+ [
+ "openai/whisper-large-v3",
+ "openai/gpt-4o-transcribe",
+ "openai/gpt-4o-mini-transcribe",
+ "openai/whisper-1",
+ "openai/whisper-large-v3-turbo",
+ "google/chirp-3",
+ "mistralai/voxtral-mini-transcribe",
+ "qwen/qwen3-asr-flash-2026-02-10",
+ "nvidia/parakeet-tdt-0.6b-v3",
+ "microsoft/mai-transcribe-1.5",
+ ]
+ ),
}
@@ -394,8 +607,8 @@ class CatalogSpec:
"""Per-provider picker spec: which tier, what it selects, the curated list,
and whether a live ``/v1/models`` fetch is available (brain providers only)."""
- tier: str # "brain" | "tts" | "stt"
- selects: str # "model" | "voice"
+ tier: str # "brain" | "tts" | "stt"
+ selects: str # "model" | "voice"
curated: tuple[ModelInfo, ...]
live: bool
@@ -410,14 +623,23 @@ def _build_provider_catalog() -> dict[str, CatalogSpec]:
# /v1/models over OAuth, so curated only. The concrete GPT-5.6 choices are
# the current Codex lineup; the still-supported GPT-5.5/5.4 choices remain
# available for users who intentionally prefer their established behavior.
- cat["codex"] = CatalogSpec("brain", "model", tuple(_curated([
- ("gpt-5.6-sol", "GPT-5.6 Sol"),
- ("gpt-5.6-terra", "GPT-5.6 Terra"),
- ("gpt-5.6-luna", "GPT-5.6 Luna"),
- ("gpt-5.5", "GPT-5.5"),
- ("gpt-5.4", "GPT-5.4"),
- ("gpt-5.4-mini", "GPT-5.4 Mini"),
- ])), live=False)
+ cat["codex"] = CatalogSpec(
+ "brain",
+ "model",
+ tuple(
+ _curated(
+ [
+ ("gpt-5.6-sol", "GPT-5.6 Sol"),
+ ("gpt-5.6-terra", "GPT-5.6 Terra"),
+ ("gpt-5.6-luna", "GPT-5.6 Luna"),
+ ("gpt-5.5", "GPT-5.5"),
+ ("gpt-5.4", "GPT-5.4"),
+ ("gpt-5.4-mini", "GPT-5.4 Mini"),
+ ]
+ )
+ ),
+ live=False,
+ )
# Antigravity — subagent model catalog for the official agy/gemini CLI
# (OAuth login); no /v1/models over OAuth, so curated only. Flash first =
# the fast default; Pro is the deep option. Both are valid gemini-CLI ids.
@@ -426,10 +648,19 @@ def _build_provider_catalog() -> dict[str, CatalogSpec]:
# (a bogus name still answers), so agy always runs its IDE-configured default.
# The selection here therefore only takes effect on the gemini-CLI fallback
# path (and any future agy that honors the flag); for agy it is informational.
- cat["antigravity"] = CatalogSpec("brain", "model", tuple(_curated([
- ("gemini-3.5-flash", "Gemini 3.5 Flash"),
- ("gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
- ])), live=False)
+ cat["antigravity"] = CatalogSpec(
+ "brain",
+ "model",
+ tuple(
+ _curated(
+ [
+ ("gemini-3.5-flash", "Gemini 3.5 Flash"),
+ ("gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
+ ]
+ )
+ ),
+ live=False,
+ )
for p, (selects, opts) in TTS_CATALOG.items():
cat[p] = CatalogSpec("tts", selects, tuple(opts), live=False)
for p, opts in STT_CATALOG.items():
@@ -449,6 +680,7 @@ def catalog_spec(provider: str) -> CatalogSpec | None:
# Pure parsing + sorting (module-level for easy testing)
# ----------------------------------------------------------------------
+
def parse_models_response(provider: str, payload: dict) -> list[ModelInfo]:
"""Map a provider's ``/v1/models`` JSON to a flat ``list[ModelInfo]``.
@@ -459,6 +691,19 @@ def parse_models_response(provider: str, payload: dict) -> list[ModelInfo]:
Entries without a usable id are dropped.
"""
out: list[ModelInfo] = []
+ if provider == "ollama":
+ # Native /api/tags: {"models": [{"name": "qwen3.5:9b", ...}, ...]} —
+ # the installed-model list of the user's own server. DOWNLOADED models
+ # only: ``:cloud`` entries are ollama.com-proxied references, not
+ # local weights — a "local" card must never offer a path that leaves
+ # the machine (maintainer report 2026-07-25).
+ for m in payload.get("models", []) or []:
+ raw = (m.get("name") or "").strip()
+ if not raw or raw.endswith(":cloud") or m.get("remote"):
+ continue
+ out.append(ModelInfo(id=raw, label=raw))
+ return out
+
if provider == "gemini":
for m in payload.get("models", []) or []:
raw = (m.get("name") or "").removeprefix("models/").strip()
@@ -481,13 +726,15 @@ def parse_models_response(provider: str, payload: dict) -> list[ModelInfo]:
if not raw:
continue
label = (m.get("name") or "").strip() or raw # OpenRouter has a name
- out.append(ModelInfo(
- id=raw,
- label=label,
- output_modalities=_output_modalities(m),
- input_modalities=_input_modalities(m),
- supported_parameters=_supported_parameters(m),
- ))
+ out.append(
+ ModelInfo(
+ id=raw,
+ label=label,
+ output_modalities=_output_modalities(m),
+ input_modalities=_input_modalities(m),
+ supported_parameters=_supported_parameters(m),
+ )
+ )
return out
@@ -586,13 +833,15 @@ def pick_vision_model(provider: str) -> str | None:
continue
out_mods = m.get("output_modalities")
params = m.get("supported_parameters")
- candidates.append(ModelInfo(
- id=mid,
- label=str(m.get("label") or mid),
- output_modalities=tuple(out_mods) if isinstance(out_mods, list) else None,
- input_modalities=tuple(str(x) for x in inp),
- supported_parameters=tuple(params) if isinstance(params, list) else None,
- ))
+ candidates.append(
+ ModelInfo(
+ id=mid,
+ label=str(m.get("label") or mid),
+ output_modalities=tuple(out_mods) if isinstance(out_mods, list) else None,
+ input_modalities=tuple(str(x) for x in inp),
+ supported_parameters=tuple(params) if isinstance(params, list) else None,
+ )
+ )
usable = sort_models(provider, filter_brain_models(candidates))
return usable[0].id if usable else None
@@ -602,7 +851,13 @@ def pick_vision_model(provider: str) -> str | None:
#: dominates mission wall-clock (live forensic 2026-07-02: think=60.8s of a
#: 75.8s mission on a flagship model). Data, not logic; extend by adding a row.
_FAST_CLASS_MARKERS: tuple[str, ...] = (
- "flash", "haiku", "mini", "lite", "turbo", "air", "nano",
+ "flash",
+ "haiku",
+ "mini",
+ "lite",
+ "turbo",
+ "air",
+ "nano",
)
@@ -662,13 +917,15 @@ def pick_fast_vision_model(provider: str) -> str | None:
continue
out_mods = m.get("output_modalities")
params = m.get("supported_parameters")
- candidates.append(ModelInfo(
- id=mid,
- label=str(m.get("label") or mid),
- output_modalities=tuple(out_mods) if isinstance(out_mods, list) else None,
- input_modalities=tuple(str(x) for x in inp),
- supported_parameters=tuple(params) if isinstance(params, list) else None,
- ))
+ candidates.append(
+ ModelInfo(
+ id=mid,
+ label=str(m.get("label") or mid),
+ output_modalities=tuple(out_mods) if isinstance(out_mods, list) else None,
+ input_modalities=tuple(str(x) for x in inp),
+ supported_parameters=tuple(params) if isinstance(params, list) else None,
+ )
+ )
usable = sort_models(provider, filter_brain_models(candidates))
if not usable:
return None
@@ -703,9 +960,26 @@ def _output_modalities(entry: dict) -> tuple[str, ...] | None:
# Gemini catalog in particular front-loads Veo/Imagen/Lyria/Nano-Banana. A truly
# exotic model is still reachable via the free-text custom entry.
_NON_BRAIN_MARKERS: tuple[str, ...] = (
- "veo", "imagen", "lyria", "nano-banana", "dall-e", "dalle", "sora",
- "whisper", "transcrib", "speech", "tts", "-audio", "audio-",
- "embed", "image", "moderation", "rerank", "realtime", "-live", "guard",
+ "veo",
+ "imagen",
+ "lyria",
+ "nano-banana",
+ "dall-e",
+ "dalle",
+ "sora",
+ "whisper",
+ "transcrib",
+ "speech",
+ "tts",
+ "-audio",
+ "audio-",
+ "embed",
+ "image",
+ "moderation",
+ "rerank",
+ "realtime",
+ "-live",
+ "guard",
)
@@ -714,9 +988,15 @@ _NON_BRAIN_MARKERS: tuple[str, ...] = (
# it is pure noise in the picker). NOTE: this is about OUTPUT only; a model that
# ACCEPTS image INPUT (vision) but outputs text is a valid — even required —
# brain (Computer-Use needs vision-input), so input modalities are NOT filtered.
-_GENERATION_OUTPUT_MODALITIES: frozenset[str] = frozenset({
- "image", "audio", "video", "music", "speech",
-})
+_GENERATION_OUTPUT_MODALITIES: frozenset[str] = frozenset(
+ {
+ "image",
+ "audio",
+ "video",
+ "music",
+ "speech",
+ }
+)
def filter_brain_models(models: list[ModelInfo]) -> list[ModelInfo]:
@@ -787,15 +1067,34 @@ def _is_stale(provider: str, model_id: str) -> bool:
# anything, so this is a sensible default order, not a hard curation.
_FAMILY_RANK: tuple[tuple[str, int], ...] = (
# Flagship frontier
- ("claude-opus", 39), ("claude-fable", 39), ("claude-sonnet", 38),
- ("gpt-5", 37), ("gemini-3", 36), ("grok-4", 35), ("claude-haiku", 33),
+ ("claude-opus", 39),
+ ("claude-fable", 39),
+ ("claude-sonnet", 38),
+ ("gpt-5", 37),
+ ("gemini-3", 36),
+ ("grok-4", 35),
+ ("claude-haiku", 33),
# Popular / strong value
- ("deepseek", 29), ("kimi", 28), ("glm-5", 27), ("qwen3", 26),
- ("qwen-3", 26), ("glm-4", 25), ("llama-4", 24), ("mistral-large", 23),
- ("mistral-medium", 22), ("gpt-oss", 21), ("command-r", 20),
+ ("deepseek", 29),
+ ("kimi", 28),
+ ("glm-5", 27),
+ ("qwen3", 26),
+ ("qwen-3", 26),
+ ("glm-4", 25),
+ ("llama-4", 24),
+ ("mistral-large", 23),
+ ("mistral-medium", 22),
+ ("gpt-oss", 21),
+ ("command-r", 20),
# Older-but-mainstream
- ("gpt-4", 15), ("gemini-2", 14), ("grok-3", 13), ("llama-3", 12),
- ("mistral", 11), ("qwen", 10), ("glm", 10), ("command", 9),
+ ("gpt-4", 15),
+ ("gemini-2", 14),
+ ("grok-3", 13),
+ ("llama-3", 12),
+ ("mistral", 11),
+ ("qwen", 10),
+ ("glm", 10),
+ ("command", 9),
)
@@ -847,16 +1146,18 @@ def _squash(text: str) -> str:
# stripped) so the same pick is starred whether it comes from a direct provider
# (``claude-opus-4-8``) or OpenRouter (``anthropic/claude-opus-4.8``). Extend
# freely — this is a curated favourites list, presentation only.
-STARRED_MODELS: frozenset[str] = frozenset({
- _squash("claude-opus-4.8"), # Opus 4.8
- _squash("claude-opus-4.8-fast"), # Opus 4.8 (Fast)
- _squash("gpt-5.6"), # GPT-5.6 alias (direct OpenAI)
- _squash("gpt-5.6-sol"), # GPT-5.6 flagship (OpenAI/OpenRouter)
- _squash("gpt-5.5"), # GPT-5.5
- _squash("gemini-3.5-flash"), # Gemini 3.5 Flash
- _squash("claude-fable-5"), # Fable 5
- _squash("glm-5.2"), # GLM-5.2
-})
+STARRED_MODELS: frozenset[str] = frozenset(
+ {
+ _squash("claude-opus-4.8"), # Opus 4.8
+ _squash("claude-opus-4.8-fast"), # Opus 4.8 (Fast)
+ _squash("gpt-5.6"), # GPT-5.6 alias (direct OpenAI)
+ _squash("gpt-5.6-sol"), # GPT-5.6 flagship (OpenAI/OpenRouter)
+ _squash("gpt-5.5"), # GPT-5.5
+ _squash("gemini-3.5-flash"), # Gemini 3.5 Flash
+ _squash("claude-fable-5"), # Fable 5
+ _squash("glm-5.2"), # GLM-5.2
+ }
+)
def is_free_model(model_id: str, label: str = "") -> bool:
@@ -903,12 +1204,21 @@ def classify_model(model_id: str, label: str = "") -> ModelTags:
# special-purpose siblings rarely wanted as the default pick. The full flagship
# (incl. ``-pro``) is NOT demoted.
_SPECIALIZED_MARKERS: tuple[str, ...] = (
- "-mini", "-nano", "-lite", ":free", "-codex", "-chat",
- "-search", "-air", "-flash-lite",
+ "-mini",
+ "-nano",
+ "-lite",
+ ":free",
+ "-codex",
+ "-chat",
+ "-search",
+ "-air",
+ "-flash-lite",
# Special-purpose siblings — not the default chat brain, so they rank below
# the plain model of the same family. (Image/audio variants are already
# dropped upstream by filter_brain_models, so they need no marker here.)
- "-deep-research", "-multi-agent", "-customtools",
+ "-deep-research",
+ "-multi-agent",
+ "-customtools",
)
@@ -1003,6 +1313,7 @@ def sort_models(provider: str, models: list[ModelInfo]) -> list[ModelInfo]:
# Catalog with cache + live fetch + static fallback
# ----------------------------------------------------------------------
+
class ModelCatalog:
"""Live model lists per provider with a TTL cache and honest fallbacks."""
@@ -1090,7 +1401,8 @@ class ModelCatalog:
for prov, (ts, models) in self._cache.items()
}
self._cache_path.write_text(
- json.dumps(data, indent=2), encoding="utf-8",
+ json.dumps(data, indent=2),
+ encoding="utf-8",
)
def _is_fresh(self, provider: str, fetched_at: float) -> bool:
@@ -1107,9 +1419,7 @@ class ModelCatalog:
# -- public API ----------------------------------------------------
- async def list_models(
- self, provider: str, *, force_refresh: bool = False
- ) -> CatalogResult:
+ async def list_models(self, provider: str, *, force_refresh: bool = False) -> CatalogResult:
"""Return the catalog for ``provider`` with an honest ``source`` flag.
Brain providers with a live endpoint: fresh cache → ``cache`` (no
@@ -1138,7 +1448,11 @@ class ModelCatalog:
cached = self._cache.get(provider)
if cached and not force_refresh and self._is_fresh(provider, cached[0]):
return CatalogResult(
- provider, self._present(provider, cached[1]), "cache", cached[0], "model",
+ provider,
+ self._present(provider, cached[1]),
+ "cache",
+ cached[0],
+ "model",
)
try:
@@ -1147,18 +1461,30 @@ class ModelCatalog:
log.info("Model catalog fetch for %s failed: %s", provider, exc)
if cached:
return CatalogResult(
- provider, self._present(provider, cached[1]), "cache", cached[0], "model",
+ provider,
+ self._present(provider, cached[1]),
+ "cache",
+ cached[0],
+ "model",
)
static = self._static_fallback(provider)
return CatalogResult(
- provider, self._present(provider, static), "static", 0.0, "model",
+ provider,
+ self._present(provider, static),
+ "static",
+ 0.0,
+ "model",
)
now = time.time()
self._cache[provider] = (now, models)
self._save_cache()
return CatalogResult(
- provider, self._present(provider, models), "live", now, "model",
+ provider,
+ self._present(provider, models),
+ "live",
+ now,
+ "model",
)
# -- network -------------------------------------------------------
@@ -1168,15 +1494,49 @@ class ModelCatalog:
return self._client_factory() # type: ignore[operator]
return httpx.AsyncClient(timeout=12.0)
+ @staticmethod
+ def _resolve_catalog_url(provider: str, ep: _CatalogEndpoint) -> str:
+ """The effective catalog URL: team proxy → base_url override → vendor
+ default, composed with the provider's ``path``.
+
+ Local providers store a bare SERVER ROOT (a pasted ``…/v1`` is
+ normalized away, ollama honors OLLAMA_HOST); cloud providers compose
+ exactly like the former static table with no override configured.
+ """
+ if provider in ("ollama", "local-openai"):
+ # Lazy plugin import (pure helpers) — keeps module import light.
+ from jarvis.plugins.brain.ollama import (
+ default_server_root,
+ normalize_server_root,
+ )
+
+ vendor_default = default_server_root() if provider == "ollama" else None
+ resolved = cfg.resolve_provider_endpoint(
+ provider, vendor_default_base_url=vendor_default
+ )
+ if not resolved.base_url:
+ raise RuntimeError(
+ "No server URL configured for the local OpenAI-compatible "
+ "provider — set it on the provider card first."
+ )
+ return normalize_server_root(resolved.base_url) + ep.path
+
+ resolved = cfg.resolve_provider_endpoint(provider, vendor_default_base_url=ep.vendor_base)
+ base = (resolved.base_url or "").rstrip("/")
+ return base + ep.path
+
async def _fetch_raw(self, provider: str) -> list[ModelInfo]:
"""Call ``provider``'s catalog endpoint and parse it. Raises on no key
- (except OpenRouter, whose catalog is public) or a transport/HTTP error."""
+ (public catalogs and keyless local providers excepted) or a
+ transport/HTTP error."""
if provider not in _ENDPOINTS:
raise ValueError(f"Unsupported provider: {provider}")
- url, auth = _ENDPOINTS[provider]
+ ep = _ENDPOINTS[provider]
+ url = self._resolve_catalog_url(provider, ep)
key = cfg.get_provider_secret(provider)
- if not key and auth != "bearer_opt":
+ if not key and ep.auth in ("x-api-key", "bearer", "query"):
raise RuntimeError(f"No API key configured for {provider}.")
+ auth = ep.auth
headers: dict[str, str] = {}
params: dict[str, str] = {}
@@ -1189,6 +1549,12 @@ class ModelCatalog:
headers = {"Authorization": f"Bearer {key}"}
elif auth == "query":
params = {"key": key or ""}
+ elif auth == "none" and ep.secret_slot is not None:
+ # Keyless local server with an OPTIONAL stored key (e.g. vLLM
+ # --api-key): attach it when present, stay anonymous otherwise.
+ optional = cfg.get_secret(*ep.secret_slot)
+ if optional:
+ headers = {"Authorization": f"Bearer {optional}"}
client = await self._client()
async with client:
diff --git a/jarvis/plugins/brain/ollama.py b/jarvis/plugins/brain/ollama.py
index d855e3b6e8..78c03b71a4 100644
--- a/jarvis/plugins/brain/ollama.py
+++ b/jarvis/plugins/brain/ollama.py
@@ -15,8 +15,10 @@ stalling. Tool calling rides the OpenAI-compat layer (``tool_choice`` is not
used on the pipeline path); reliability is model-dependent — the qwen line is
the recommended pull.
-Model discovery is NATIVE (``/api/tags``): with no configured model the brain
-runs the first installed one, and a model-less server produces an honest
+Model discovery is NATIVE (``/api/tags`` + ``/api/show``): with no configured
+model the brain runs the smallest DOWNLOADED model whose declared capabilities
+match the turn (``completion``, plus ``tools`` for tool turns); ``:cloud``
+references never count as local, and a model-less server produces an honest
"pull one first" error instead of a hardcoded default that would 404.
"""
@@ -92,6 +94,10 @@ class OllamaBrain:
self._client: Any = None
self._server_root: str | None = None
self._credential: str | None = None
+ # Discovery cache per requirement profile (False = plain chat,
+ # True = chat + tools) — a tool-less turn may run a smaller model
+ # than a tool turn without re-asking the server every time.
+ self._discovered: dict[bool, str] = {}
def can_call_tools(self) -> bool:
return self.supports_tools
@@ -122,10 +128,24 @@ class OllamaBrain:
)
return self._client
- async def _resolve_model(self) -> str:
- """The configured model, else the first installed one (``/api/tags``)."""
+ async def _resolve_model(self, *, need_tools: bool = False) -> str:
+ """The configured model, else the smallest CAPABLE download.
+
+ Hard rules for the silent default (three live incidents 2026-07-25):
+ ``:cloud`` entries are ollama.com-proxied references, not local
+ weights — a "local" brain must never route through them. Among the
+ real downloads the SMALLEST wins (the former first-installed pick
+ landed on a 30B model whose 256k default context needed 45 GB on a
+ 32 GB box and froze the whole desktop) — but only one whose DECLARED
+ ``/api/show`` capabilities match the turn: ``completion`` always
+ (bge-m3 would 400 on chat), plus ``tools`` when the request carries
+ tools (deepseek-llm 400s on a tool turn). The user's explicit model
+ pick always overrides this.
+ """
if self._model:
return self._model
+ if need_tools in self._discovered:
+ return self._discovered[need_tools]
root = self._resolve_root()
try:
async with httpx.AsyncClient(timeout=CLIENT_TIMEOUT) as client:
@@ -137,20 +157,62 @@ class OllamaBrain:
f"Ollama not reachable at {root} — is it running? Start it "
"(or install from https://ollama.com/download), then retry."
) from exc
- names = [str(m.get("name") or "").strip() for m in models]
- names = [n for n in names if n]
- if not names:
+ local = [
+ m
+ for m in models
+ if (name := str(m.get("name") or "").strip())
+ and not name.endswith(":cloud")
+ and not m.get("remote")
+ ]
+ if not local:
raise RuntimeError(
- f"Ollama at {root} has no models installed — run: "
- f"ollama pull {RECOMMENDED_PULL}, then retry."
+ f"Ollama at {root} has no downloaded models (cloud references "
+ f"do not count) — run: ollama pull {RECOMMENDED_PULL}, then retry."
)
- self._model = names[0]
- log.info("ollama: no model configured — using first installed: %s", self._model)
- return self._model
+ local.sort(key=lambda m: int(m.get("size") or 0))
+ for m in local:
+ name = str(m.get("name")).strip()
+ caps = await self._capabilities(name, root)
+ if caps is not None:
+ if "completion" not in caps:
+ continue
+ if need_tools and "tools" not in caps:
+ continue
+ self._discovered[need_tools] = name
+ log.info(
+ "ollama: no model configured — using smallest capable download (tools=%s): %s",
+ need_tools,
+ name,
+ )
+ return name
+ wanted = "chat + tool calling" if need_tools else "chat"
+ raise RuntimeError(
+ f"None of the models downloaded at {root} supports {wanted} — run: "
+ f"ollama pull {RECOMMENDED_PULL}, then retry."
+ )
+
+ @staticmethod
+ async def _capabilities(name: str, root: str) -> set[str] | None:
+ """DECLARED capabilities of one download via native ``/api/show``.
+
+ Gate on capability, never the model name (AP-21). ``None`` = the probe
+ could not answer — the caller FAILS OPEN and accepts the candidate (a
+ probe glitch must never brick the pick; the real call then errors
+ honestly)."""
+ try:
+ async with httpx.AsyncClient(timeout=CLIENT_TIMEOUT) as client:
+ resp = await client.post(f"{root}/api/show", json={"model": name})
+ resp.raise_for_status()
+ caps = resp.json().get("capabilities")
+ except Exception: # noqa: BLE001 — probe glitch must not block the pick
+ return None
+ if not isinstance(caps, list):
+ return None
+ return {str(c) for c in caps}
async def complete(self, req: BrainRequest) -> AsyncIterator[BrainDelta]:
client = self._ensure_client()
- model = await self._resolve_model()
+ model = await self._resolve_model(need_tools=bool(req.tools))
async for delta in stream_complete(client, model, req):
yield delta
diff --git a/tests/unit/brain/test_model_catalog_local.py b/tests/unit/brain/test_model_catalog_local.py
new file mode 100644
index 0000000000..923f37294f
--- /dev/null
+++ b/tests/unit/brain/test_model_catalog_local.py
@@ -0,0 +1,362 @@
+"""Model-catalog behavior pins: cloud regression half (S3a) + local providers.
+
+REGRESSION HALF (written and committed green BEFORE the endpoint refactor,
+maintainer amendment 2026-07-25): for every cloud catalog provider this pins
+the OBSERVABLE fetch behavior — exact URL, auth attachment shape, no-key
+behavior, and the bearer_opt anonymous retry — plus the parser output per
+payload shape. The refactor that makes endpoints resolve through
+``resolve_provider_endpoint`` MUST keep every one of these green without
+touching this file: with no base-url override configured, cloud behavior is
+byte-identical.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+import pytest
+
+import jarvis.core.config as cfg
+from jarvis.brain.model_catalog import (
+ CATALOG_PROVIDERS,
+ ModelCatalog,
+ parse_models_response,
+)
+from jarvis.core.config import JarvisConfig
+
+
+class _FakeResponse:
+ def __init__(self, payload: dict[str, Any], status_code: int = 200) -> None:
+ self._payload = payload
+ self.status_code = status_code
+
+ def raise_for_status(self) -> None:
+ if self.status_code >= 400:
+ raise RuntimeError(f"HTTP {self.status_code}")
+
+ def json(self) -> dict[str, Any]:
+ return self._payload
+
+
+class _FakeClient:
+ """Records every GET; optionally rejects the first (authed) call with 401."""
+
+ def __init__(self, payload: dict[str, Any], reject_authed: bool = False) -> None:
+ self.payload = payload
+ self.reject_authed = reject_authed
+ self.calls: list[dict[str, Any]] = []
+
+ async def __aenter__(self) -> _FakeClient:
+ return self
+
+ async def __aexit__(self, *exc: Any) -> None:
+ return None
+
+ async def get(
+ self,
+ url: str,
+ headers: dict[str, str] | None = None,
+ params: dict[str, str] | None = None,
+ ) -> _FakeResponse:
+ self.calls.append({"url": url, "headers": headers or {}, "params": params or {}})
+ if self.reject_authed and headers and "Authorization" in headers:
+ return _FakeResponse({}, status_code=401)
+ return _FakeResponse(self.payload)
+
+
+def _catalog(tmp_path, client: _FakeClient) -> ModelCatalog:
+ return ModelCatalog(
+ cache_path=tmp_path / "cache.json",
+ http_client_factory=lambda: client,
+ )
+
+
+def _plain_env(monkeypatch, keys: dict[str, str | None]) -> None:
+ """No base-url overrides, no team proxy — the stock cloud setup."""
+ monkeypatch.setattr(cfg, "load_config", lambda: JarvisConfig())
+ monkeypatch.setattr(cfg, "get_provider_secret", lambda pid: keys.get(pid))
+
+
+_OPENAI_SHAPE = {"data": [{"id": "model-b"}, {"id": "model-a"}]}
+_GEMINI_SHAPE = {"models": [{"name": "models/gemini-x", "displayName": "Gemini X"}]}
+
+# The pinned cloud contract: provider → (URL, auth shape). Deliberately a
+# LITERAL copy, not an import of _ENDPOINTS — the whole point is detecting an
+# accidental change of the wire behavior during the endpoint refactor.
+_PINNED: dict[str, tuple[str, str]] = {
+ "claude-api": ("https://api.anthropic.com/v1/models", "x-api-key"),
+ "openai": ("https://api.openai.com/v1/models", "bearer"),
+ "gemini": ("https://generativelanguage.googleapis.com/v1beta/models", "query"),
+ "openrouter": ("https://openrouter.ai/api/v1/models", "bearer_opt"),
+ "grok": ("https://api.x.ai/v1/models", "bearer"),
+ "nvidia": ("https://integrate.api.nvidia.com/v1/models", "bearer_opt"),
+}
+
+
+def test_pinned_contract_covers_every_cloud_catalog_provider() -> None:
+ """A provider added to CATALOG_PROVIDERS must be pinned here (or is local,
+ covered by the local half below)."""
+ cloud = [p for p in CATALOG_PROVIDERS if p in _PINNED]
+ assert set(cloud) == set(_PINNED), (
+ "CATALOG_PROVIDERS and the pinned cloud contract diverged — pin the new "
+ "provider's URL + auth shape here before shipping it"
+ )
+
+
[email protected]("provider", sorted(_PINNED))
+async def test_cloud_fetch_url_and_auth_are_byte_identical(
+ provider: str, tmp_path, monkeypatch
+) -> None:
+ url, auth = _PINNED[provider]
+ payload = _GEMINI_SHAPE if provider == "gemini" else _OPENAI_SHAPE
+ client = _FakeClient(payload)
+ _plain_env(monkeypatch, {provider: "sk-pin-test"})
+
+ result = await _catalog(tmp_path, client).list_models(provider)
+
+ assert result.source == "live"
+ assert len(client.calls) == 1
+ call = client.calls[0]
+ assert call["url"] == url
+ if auth == "x-api-key":
+ assert call["headers"] == {
+ "x-api-key": "sk-pin-test",
+ "anthropic-version": "2023-06-01",
+ }
+ assert call["params"] == {}
+ elif auth == "bearer":
+ assert call["headers"] == {"Authorization": "Bearer sk-pin-test"}
+ assert call["params"] == {}
+ elif auth == "bearer_opt":
+ assert call["headers"] == {"Authorization": "Bearer sk-pin-test"}
+ assert call["params"] == {}
+ elif auth == "query":
+ assert call["headers"] == {}
+ assert call["params"] == {"key": "sk-pin-test"}
+
+
+ "provider", sorted(p for p, (_, a) in _PINNED.items() if a in ("x-api-key", "bearer", "query"))
+)
+async def test_keyed_cloud_provider_without_key_never_fetches(
+ provider: str, tmp_path, monkeypatch
+) -> None:
+ """No key → no network call; the picker gets the honest static fallback."""
+ client = _FakeClient(_OPENAI_SHAPE)
+ _plain_env(monkeypatch, {})
+
+ result = await _catalog(tmp_path, client).list_models(provider)
+
+ assert result.source == "static"
+ assert client.calls == []
+ assert result.models, "static fallback must still offer a useful list"
+
+
+ "provider", sorted(p for p, (_, a) in _PINNED.items() if a == "bearer_opt")
+)
+async def test_public_catalog_fetches_anonymously_without_key(
+ provider: str, tmp_path, monkeypatch
+) -> None:
+ client = _FakeClient(_OPENAI_SHAPE)
+ _plain_env(monkeypatch, {})
+
+ result = await _catalog(tmp_path, client).list_models(provider)
+
+ assert result.source == "live"
+ assert len(client.calls) == 1
+ assert "Authorization" not in client.calls[0]["headers"]
+
+
+ "provider", sorted(p for p, (_, a) in _PINNED.items() if a == "bearer_opt")
+)
+async def test_public_catalog_retries_anonymously_on_rejected_key(
+ provider: str, tmp_path, monkeypatch
+) -> None:
+ """A stale optional key must not hide a PUBLIC catalog (pinned behavior:
+ one authed attempt, then one anonymous retry)."""
+ client = _FakeClient(_OPENAI_SHAPE, reject_authed=True)
+ _plain_env(monkeypatch, {provider: "sk-stale"})
+
+ result = await _catalog(tmp_path, client).list_models(provider)
+
+ assert result.source == "live"
+ assert len(client.calls) == 2
+ assert client.calls[0]["headers"] == {"Authorization": "Bearer sk-stale"}
+ assert "Authorization" not in client.calls[1]["headers"]
+
+
+# ── Parser pins (shapes the refactor must not disturb) ───────────────────
+def test_parser_openai_compatible_shape() -> None:
+ models = parse_models_response("openai", {"data": [{"id": "gpt-x"}, {"id": ""}]})
+ assert [(m.id, m.label) for m in models] == [("gpt-x", "gpt-x")]
+
+
+def test_parser_openrouter_uses_human_name_as_label() -> None:
+ models = parse_models_response("openrouter", {"data": [{"id": "a/b", "name": "A B"}]})
+ assert [(m.id, m.label) for m in models] == [("a/b", "A B")]
+
+
+def _local_env(
+ monkeypatch,
+ *,
+ base_urls: dict[str, str] | None = None,
+ stored_local_key: str | None = None,
+) -> None:
+ """Hermetic env for the LOCAL providers: optional base-url overrides, no
+ real keyring, no ambient OLLAMA_HOST."""
+ from jarvis.core.config import BrainConfig, BrainProviderConfig
+
+ providers = {pid: BrainProviderConfig(base_url=url) for pid, url in (base_urls or {}).items()}
+ conf = JarvisConfig(brain=BrainConfig(providers=providers))
+ monkeypatch.setattr(cfg, "load_config", lambda: conf)
+ monkeypatch.setattr(cfg, "get_provider_secret", lambda pid: None)
+ monkeypatch.setattr(
+ cfg,
+ "get_secret",
+ lambda key, env=None: stored_local_key if key == "local_openai_api_key" else None,
+ )
+ monkeypatch.delenv("OLLAMA_HOST", raising=False)
+
+
+_OLLAMA_TAGS = {"models": [{"name": "qwen3.5:9b"}, {"name": "glm-5.1:latest"}]}
+
+
+def test_parser_ollama_lists_downloaded_models_only() -> None:
+ """The picker must show what the user actually HOLDS: ``:cloud`` entries
+ are ollama.com-proxied references (maintainer report 2026-07-25), and
+ ``remote`` entries likewise never represent local weights."""
+ payload = {
+ "models": [
+ {"name": "qwen2.5:7b"},
+ {"name": "kimi-k2.5:cloud"},
+ {"name": "other-remote", "remote": True},
+ ]
+ }
+ models = parse_models_response("ollama", payload)
+ assert [m.id for m in models] == ["qwen2.5:7b"]
+
+
+# ── Local half (S3b): ollama /api/tags ───────────────────────────────────
+async def test_ollama_fetches_tags_keyless(tmp_path, monkeypatch) -> None:
+ client = _FakeClient(_OLLAMA_TAGS)
+ _local_env(monkeypatch)
+
+ result = await _catalog(tmp_path, client).list_models("ollama")
+
+ assert result.source == "live"
+ # The picker applies its relevance sort — pin membership, not order.
+ assert {m.id for m in result.models} == {"qwen3.5:9b", "glm-5.1:latest"}
+ assert len(client.calls) == 1
+ call = client.calls[0]
+ assert call["url"] == "http://localhost:11434/api/tags"
+ assert call["headers"] == {}
+ assert call["params"] == {}
+
+
+async def test_ollama_honors_base_url_override(tmp_path, monkeypatch) -> None:
+ """A pasted ``…/v1`` override is normalized to the server root first."""
+ client = _FakeClient(_OLLAMA_TAGS)
+ _local_env(monkeypatch, base_urls={"ollama": "http://gpu.lan:11434/v1/"})
+
+ await _catalog(tmp_path, client).list_models("ollama")
+
+ assert client.calls[0]["url"] == "http://gpu.lan:11434/api/tags"
+
+
+async def test_ollama_honors_ollama_host_env(tmp_path, monkeypatch) -> None:
+ client = _FakeClient(_OLLAMA_TAGS)
+ _local_env(monkeypatch)
+ monkeypatch.setenv("OLLAMA_HOST", "0.0.0.0:12345")
+
+ await _catalog(tmp_path, client).list_models("ollama")
+
+ # 0.0.0.0 is a bind address, not a client target — mapped to localhost.
+ assert client.calls[0]["url"] == "http://localhost:12345/api/tags"
+
+
+async def test_ollama_unreachable_returns_honest_empty_static(tmp_path, monkeypatch) -> None:
+ """No fake curated list for a local provider: dead server → empty models,
+ honest ``static`` source (the card's test button explains the fix)."""
+
+ class _DeadClient(_FakeClient):
+ async def get(self, url, headers=None, params=None): # type: ignore[override]
+ raise RuntimeError("connection refused")
+
+ _local_env(monkeypatch)
+
+ result = await _catalog(tmp_path, _DeadClient({})).list_models("ollama")
+
+ assert result.source == "static"
+ assert result.models == ()
+
+
+# ── Local half (S3b): local-openai /v1/models ────────────────────────────
+async def test_local_openai_without_base_url_is_honestly_empty(tmp_path, monkeypatch) -> None:
+ """No configured server → no network call, no fake list, no crash."""
+ client = _FakeClient(_OPENAI_SHAPE)
+ _local_env(monkeypatch)
+
+ result = await _catalog(tmp_path, client).list_models("local-openai")
+
+ assert result.source == "static"
+ assert result.models == ()
+ assert client.calls == []
+
+
+async def test_local_openai_fetches_v1_models_from_override(tmp_path, monkeypatch) -> None:
+ client = _FakeClient({"data": [{"id": "Qwen/Qwen3.5-9B"}]})
+ _local_env(monkeypatch, base_urls={"local-openai": "http://localhost:8000"})
+
+ result = await _catalog(tmp_path, client).list_models("local-openai")
+
+ assert result.source == "live"
+ assert [m.id for m in result.models] == ["Qwen/Qwen3.5-9B"]
+ call = client.calls[0]
+ assert call["url"] == "http://localhost:8000/v1/models"
+ assert call["headers"] == {}
+
+
+async def test_local_openai_attaches_optional_stored_key(tmp_path, monkeypatch) -> None:
+ client = _FakeClient({"data": [{"id": "m"}]})
+ _local_env(
+ monkeypatch,
+ base_urls={"local-openai": "http://localhost:8000"},
+ stored_local_key="sk-local-pin",
+ )
+
+ await _catalog(tmp_path, client).list_models("local-openai")
+
+ assert client.calls[0]["headers"] == {"Authorization": "Bearer sk-local-pin"}
+
+
+def test_local_ttl_capped_near_live(tmp_path) -> None:
+ """The installed-model set changes with every pull/restart — a local
+ catalog older than 60 s is stale even under the 6 h default TTL."""
+ catalog = _catalog(tmp_path, _FakeClient({}))
+ import time as _time
+
+ two_minutes_ago = _time.time() - 120
+ assert catalog._is_fresh("openai", two_minutes_ago) is True
+ assert catalog._is_fresh("ollama", two_minutes_ago) is False
+ assert catalog._is_fresh("local-openai", two_minutes_ago) is False
+
+
+def test_parser_ollama_tags_shape() -> None:
+ models = parse_models_response("ollama", {"models": [{"name": "qwen3.5:9b"}, {"name": ""}]})
+ assert [(m.id, m.label) for m in models] == [("qwen3.5:9b", "qwen3.5:9b")]
+
+
+def test_parser_gemini_strips_prefix_and_gates_on_generate_content() -> None:
+ payload = {
+ "models": [
+ {"name": "models/gemini-x", "displayName": "Gemini X"},
+ {
+ "name": "models/embedding-001",
+ "supportedGenerationMethods": ["embedContent"],
+ },
+ ]
+ }
+ models = parse_models_response("gemini", payload)
+ assert [(m.id, m.label) for m in models] == [("gemini-x", "Gemini X")]
diff --git a/tests/unit/plugins/brain/test_ollama.py b/tests/unit/plugins/brain/test_ollama.py
index b1863358c1..ad9b06ede5 100644
--- a/tests/unit/plugins/brain/test_ollama.py
+++ b/tests/unit/plugins/brain/test_ollama.py
@@ -136,6 +136,9 @@ class _FakeAsyncClient:
payload: dict[str, Any] = {}
fail: bool = False
last_url: str | None = None
+ # /api/show capability map: model name -> capabilities list. Models absent
+ # from the map answer with a chat-capable default.
+ show_caps: dict[str, list[str]] = {}
def __init__(self, **kwargs: Any) -> None:
pass
@@ -152,6 +155,12 @@ class _FakeAsyncClient:
raise httpx.ConnectError("connection refused")
return _FakeResponse(_FakeAsyncClient.payload)
+ async def post(self, url: str, json: dict[str, Any] | None = None) -> _FakeResponse:
+ assert url.endswith("/api/show")
+ name = str((json or {}).get("model") or "")
+ caps = _FakeAsyncClient.show_caps.get(name, ["completion", "tools"])
+ return _FakeResponse({"capabilities": caps})
+
@pytest.fixture()
def fake_tags(monkeypatch):
@@ -159,6 +168,7 @@ def fake_tags(monkeypatch):
_FakeAsyncClient.fail = False
_FakeAsyncClient.payload = {}
_FakeAsyncClient.last_url = None
+ _FakeAsyncClient.show_caps = {}
return _FakeAsyncClient
@@ -169,15 +179,93 @@ async def test_configured_model_skips_discovery(monkeypatch, fake_tags) -> None:
assert fake_tags.last_url is None # no HTTP call
-async def test_discovery_uses_first_installed_model(monkeypatch, fake_tags) -> None:
+async def test_discovery_uses_smallest_downloaded_model(monkeypatch, fake_tags) -> None:
+ """Live incident 2026-07-25: the first-installed pick loaded a 30B model
+ (45 GB at its 256k default context) on a 32 GB box and froze the desktop.
+ The silent default is the SMALLEST download; the user's pick wins."""
_no_override(monkeypatch)
- fake_tags.payload = {"models": [{"name": "qwen3.5:9b"}, {"name": "gemma4:12b"}]}
+ fake_tags.payload = {
+ "models": [
+ {"name": "qwen3-coder:30b", "size": 18_000_000_000},
+ {"name": "qwen2.5:7b", "size": 4_700_000_000},
+ {"name": "deepseek-r1:14b", "size": 9_000_000_000},
+ ]
+ }
brain = OllamaBrain()
- assert await brain._resolve_model() == "qwen3.5:9b"
+ assert await brain._resolve_model() == "qwen2.5:7b"
assert fake_tags.last_url == "http://localhost:11434/api/tags"
# Cached: a second resolve must not depend on the server again.
fake_tags.fail = True
- assert await brain._resolve_model() == "qwen3.5:9b"
+ assert await brain._resolve_model() == "qwen2.5:7b"
+
+
+async def test_discovery_never_picks_a_cloud_reference(monkeypatch, fake_tags) -> None:
+ """``:cloud`` tags are ollama.com-proxied references, not local weights —
+ the LOCAL brain must never default onto a path that leaves the machine."""
+ _no_override(monkeypatch)
+ fake_tags.payload = {
+ "models": [
+ {"name": "kimi-k2.5:cloud", "size": 1},
+ {"name": "remote-thing", "size": 2, "remote": True},
+ {"name": "qwen2.5:7b", "size": 4_700_000_000},
+ ]
+ }
+ assert await OllamaBrain()._resolve_model() == "qwen2.5:7b"
+
+
+async def test_discovery_skips_embedding_only_downloads(monkeypatch, fake_tags) -> None:
+ """Live incident 2026-07-25 #2: the smallest download was bge-m3, an
+ embedding-only model that 400s on chat. The default gates on the DECLARED
+ /api/show capability (never the name, AP-21) and takes the next-smallest
+ chat-capable download."""
+ _no_override(monkeypatch)
+ fake_tags.payload = {
+ "models": [
+ {"name": "bge-m3:latest", "size": 1_200_000_000},
+ {"name": "qwen2.5:7b", "size": 4_700_000_000},
+ ]
+ }
+ fake_tags.show_caps = {"bge-m3:latest": ["embedding"]}
+ assert await OllamaBrain()._resolve_model() == "qwen2.5:7b"
+
+
+async def test_tool_turns_require_a_tools_capable_download(monkeypatch, fake_tags) -> None:
+ """Live incident 2026-07-25 #3: the smallest chat-capable download had no
+ ``tools`` capability and 400ed on the first tool turn. A tool-bearing
+ request gates on the declared ``tools`` capability; plain chat may still
+ run the smaller model."""
+ _no_override(monkeypatch)
+ fake_tags.payload = {
+ "models": [
+ {"name": "deepseek-llm:latest", "size": 1_000},
+ {"name": "qwen2.5:7b", "size": 2_000},
+ ]
+ }
+ fake_tags.show_caps = {"deepseek-llm:latest": ["completion"]}
+ brain = OllamaBrain()
+ assert await brain._resolve_model() == "deepseek-llm:latest"
+ assert await brain._resolve_model(need_tools=True) == "qwen2.5:7b"
+
+
+async def test_embedding_only_server_gives_honest_error(monkeypatch, fake_tags) -> None:
+ _no_override(monkeypatch)
+ fake_tags.payload = {"models": [{"name": "bge-m3:latest", "size": 1}]}
+ fake_tags.show_caps = {"bge-m3:latest": ["embedding"]}
+ with pytest.raises(RuntimeError) as err:
+ await OllamaBrain()._resolve_model()
+ msg = str(err.value)
+ assert "supports chat" in msg
+ assert f"ollama pull {RECOMMENDED_PULL}" in msg
+
+
+async def test_cloud_only_server_gives_honest_pull_hint(monkeypatch, fake_tags) -> None:
+ _no_override(monkeypatch)
+ fake_tags.payload = {"models": [{"name": "kimi-k2.5:cloud", "size": 1}]}
+ with pytest.raises(RuntimeError) as err:
+ await OllamaBrain()._resolve_model()
+ msg = str(err.value)
+ assert f"ollama pull {RECOMMENDED_PULL}" in msg
+ assert "cloud references do not count" in msg
async def test_empty_server_gives_honest_pull_hint(monkeypatch, fake_tags) -> None: