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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(cu): vision-only Computer-Use model picker + same-provider vision rescue
Ruben Lütkea9879f8da7e5
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.pyindex 8ff70f9b36..b315e9ff2c 100644--- a/jarvis/brain/model_catalog.py+++ b/jarvis/brain/model_catalog.py@@ -333,6 +333,45 @@ def model_capabilities(provider: str, model_id: str) -> dict[str, bool | None]:return {"vision": None, "tools": None}+def pick_vision_model(provider: str) -> str | None:+ """The best vision-capable brain model of ``provider``, from the cached+ ``/v1/models`` catalog — or ``None`` when the catalog carries no modality+ data for this provider (direct provider endpoints) or no candidate exists.++ Computer-Use is screenshot-grounded: a provider whose CONFIGURED model+ cannot see images must not drop out of the CU chain when the same key+ unlocks vision-capable siblings (AP-22 — the key is fine, only the model+ choice is blind). Candidates run through the SAME brain filter + relevance+ sort as the picker, so the rescue pick equals the top row the user would+ see in the vision-filtered dropdown.+ """+ from jarvis.core import config as _cfg # noqa: PLC0415++ cache_path = _cfg.DATA_DIR / "model_catalog_cache.json"+ try:+ data = json.loads(cache_path.read_text(encoding="utf-8"))+ entries = data.get(provider, {}).get("models", [])+ except Exception: # noqa: BLE001 — missing/corrupt cache → no rescue+ return None+ candidates: list[ModelInfo] = []+ for m in entries:+ mid = str(m.get("id") or "").strip()+ inp = m.get("input_modalities")+ if not mid or not (isinstance(inp, list) and "image" in inp):+ 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,+ ))+ usable = sort_models(provider, filter_brain_models(candidates))+ return usable[0].id if usable else None++def _output_modalities(entry: dict) -> tuple[str, ...] | None:"""Pull ``architecture.output_modalities`` from a model entry as a tuple.diff --git a/jarvis/cu/brain_call.py b/jarvis/cu/brain_call.pyindex 370473c3ad..d99ba1faf8 100644--- a/jarvis/cu/brain_call.py+++ b/jarvis/cu/brain_call.py@@ -50,6 +50,48 @@ class BrainReply:PromptBuilder = Callable[[str, Any], tuple[str, str]]+def _rescue_blind_models(+ chain: list[tuple[str, str | None]],+) -> list[tuple[str, str | None]]:+ """Swap a KNOWN-blind configured model for the provider's best+ vision-capable sibling, per candidate.++ Computer-Use is screenshot-grounded; a text-only model choice (e.g. an+ OpenRouter DeepSeek pin) previously knocked the WHOLE provider out of the+ chain even though the user's key unlocks plenty of vision models — a+ "works with whatever key you have" violation (AP-22). Only an explicit+ ``vision is False`` verdict from the model catalog triggers the swap;+ unknown capability stays untouched (no regression for providers without+ modality metadata). Never raises — any lookup problem keeps the original+ pair.+ """+ try:+ from jarvis.brain.model_catalog import ( # noqa: PLC0415+ model_capabilities,+ pick_vision_model,+ )+ except Exception: # noqa: BLE001+ return chain+ rescued: list[tuple[str, str | None]] = []+ for provider, model in chain:+ try:+ if model and model_capabilities(provider, model).get("vision") is False:+ alt = pick_vision_model(provider)+ if alt and alt != model:+ logger.info(+ "[cu] %s model %s cannot see the screen — using the "+ "vision-capable %s for this mission",+ provider, model, alt,+ )+ rescued.append((provider, alt))+ continue+ except Exception: # noqa: BLE001 — rescue is best-effort+ logger.debug("[cu] vision-model rescue failed for %s", provider,+ exc_info=True)+ rescued.append((provider, model))+ return rescued++async def call_vision_brain(manager: Any,*,@@ -104,6 +146,8 @@ async def call_vision_brain(chain = resolved_chainimages_attached = bool(images)+ if images_attached:+ chain = _rescue_blind_models(chain)selector = ComputerUsePlannerSelector(manager=manager, chain=chain)attempted = 0diff --git a/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx b/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsxindex 29b3a3dcaa..126bc52012 100644--- a/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx+++ b/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx@@ -108,6 +108,7 @@ export function BrainModelSelector({headingLabel,placeholder,controlled,+ visionOnly,}: {providerId: string;currentModel?: string;@@ -139,6 +140,14 @@ export function BrainModelSelector({* behaviour (auto-pin from the catalog) is unchanged.*/controlled?: boolean;+ /**+ * Hide models that explicitly CANNOT see images (``vision === false``).+ * Used by the Computer-Use picker: CU is screenshot-grounded, so a+ * text-only model could never run it. Models with UNKNOWN capability stay+ * visible (direct provider catalogs expose no modality data). Off by+ * default — the main brain picker shows everything.+ */+ visionOnly?: boolean;}) {const t = useT();const pushToast = useEventStore((s) => s.pushToast);@@ -198,7 +207,12 @@ export function BrainModelSelector({}, [open]);const matched = useMemo(() => {- const list = Array.isArray(models) ? models : [];+ let list = Array.isArray(models) ? models : [];+ if (visionOnly) {+ // CU is screenshot-grounded: drop models that explicitly cannot see+ // images; unknown capability stays (no modality data ≠ text-only).+ list = list.filter((m) => m.vision !== false);+ }const q = query.trim().toLowerCase();if (!q) return list;// Separator-insensitive match: model ids use hyphens/slashes/dots@@ -217,7 +231,7 @@ export function BrainModelSelector({(sq.length > 0 && (squash(m.id).includes(sq) || squash(m.label).includes(sq))));});- }, [models, query]);+ }, [models, query, visionOnly]);const trimmed = query.trim();const exactMatch = matched.some((m) => m.id === trimmed);diff --git a/jarvis/ui/web/frontend/src/components/CuModelSelector.tsx b/jarvis/ui/web/frontend/src/components/CuModelSelector.tsxindex 8df75994f6..bf8fab2d86 100644--- a/jarvis/ui/web/frontend/src/components/CuModelSelector.tsx+++ b/jarvis/ui/web/frontend/src/components/CuModelSelector.tsx@@ -65,6 +65,7 @@ export function CuModelSelector({providerId={providerId}currentModel={cuModel}controlled+ visionOnlyrecommendedModel={recommendedModel}headingLabel={t("apikeys_cu_model.heading")}placeholder={t("apikeys_cu_model.use_main")}@@ -76,6 +77,9 @@ export function CuModelSelector({return res;}}/>+ <p className="text-[10px] text-muted-foreground/80">+ {t("apikeys_cu_model.vision_note")}+ </p><div className="flex items-center justify-between gap-2"><span className="text-[10px] text-muted-foreground">{usesMaindiff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.tsindex 4b6ccff52c..948c3b6ce1 100644--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts@@ -535,6 +535,11 @@ export interface BrainModel {frontier?: boolean;value?: boolean;starred?: boolean;+ // Tri-state vision-input capability from the provider's model metadata:+ // true = understands images, false = text-only, null/undefined = unknown+ // (the provider doesn't expose modality data — treated as capable). The+ // Computer-Use picker hides ONLY explicit false entries.+ vision?: boolean | null;}export interface BrainModelsResult {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex e60131e148..7df8d99564 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -904,7 +904,8 @@"use_main": "Mein Hauptmodell verwenden","using_main": "Verwendet dein Hauptmodell","effective": "Computer-Use nutzt",- "cleared": "Computer-Use-Modell auf dein Hauptmodell zurückgesetzt"+ "cleared": "Computer-Use-Modell auf dein Hauptmodell zurückgesetzt",+ "vision_note": "Es werden nur Modelle angezeigt, die Bilder verstehen - Computer-Use liest den Bildschirm über Screenshots, ein reines Text-Modell kann es nicht steuern."},"settings_view": {"silence_window": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 735da814f6..c51b16c16b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -905,7 +905,8 @@"use_main": "Use my main model","using_main": "Using your main model","effective": "Computer-Use runs",- "cleared": "Computer-Use model reset to your main model"+ "cleared": "Computer-Use model reset to your main model",+ "vision_note": "Only models that can see images are listed - Computer-Use reads the screen from screenshots, so a text-only model cannot run it."},"settings_view": {"silence_window": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 061d7f7cb1..4af701b23a 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -904,7 +904,8 @@"use_main": "Usar mi modelo principal","using_main": "Usando tu modelo principal","effective": "Computer-Use usa",- "cleared": "Modelo de Computer-Use restablecido a tu modelo principal"+ "cleared": "Modelo de Computer-Use restablecido a tu modelo principal",+ "vision_note": "Solo se muestran modelos que entienden imágenes: Computer-Use lee la pantalla mediante capturas, un modelo de solo texto no puede controlarlo."},"settings_view": {"silence_window": {diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 00c2d84ed7..f75b958d0e 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -130,6 +130,12 @@ class BrainModelInfo(BaseModel):frontier: bool = Falsevalue: bool = Falsestarred: bool = False+ # Tri-state vision-input capability from the provider's model metadata+ # (OpenRouter ``architecture.input_modalities``): True = understands+ # images, False = text-only, None = the provider endpoint does not expose+ # modality data (unknown — treated as capable, no regression). The+ # Computer-Use model picker hides ONLY explicit ``False`` entries.+ vision: bool | None = Noneclass BrainModelsResponse(BaseModel):@@ -888,6 +894,11 @@ def _brain_model_info(m: ModelInfo) -> BrainModelInfo:frontier=tags.frontier,value=tags.value,starred=tags.starred,+ vision=(+ ("image" in m.input_modalities)+ if m.input_modalities is not None+ else None+ ),)diff --git a/tests/unit/brain/test_pick_vision_model.py b/tests/unit/brain/test_pick_vision_model.pynew file mode 100644index 0000000000..410b647fbd--- /dev/null+++ b/tests/unit/brain/test_pick_vision_model.py@@ -0,0 +1,106 @@+"""Computer-Use vision-model rescue: pick_vision_model + the CU chain swap.++CU is screenshot-grounded. A text-only configured model (e.g. an OpenRouter+DeepSeek pin) must not knock its provider out of the CU chain when the same+key unlocks vision-capable siblings — the provider's best vision model is+swapped in for the mission instead (AP-22 "works with whatever key").+"""+from __future__ import annotations++import json++import jarvis.core.config as cfg+from jarvis.brain.model_catalog import pick_vision_model+from jarvis.cu.brain_call import _rescue_blind_models+++def _write_cache(tmp_path, models, provider="openrouter"):+ (tmp_path / "model_catalog_cache.json").write_text(+ json.dumps({provider: {"fetched_at": 0, "models": models}}),+ encoding="utf-8",+ )+++def test_picks_a_vision_model_and_ignores_text_only(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {"id": "x/text-only", "input_modalities": ["text"]},+ {"id": "x/multi-vl", "input_modalities": ["text", "image"]},+ ])+ assert pick_vision_model("openrouter") == "x/multi-vl"+++def test_prefers_flagship_band_over_unknown_family(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {"id": "tiny/obscure-vl", "input_modalities": ["text", "image"]},+ {+ "id": "anthropic/claude-sonnet-5",+ "input_modalities": ["text", "image", "file"],+ },+ ])+ # The picker's relevance sort puts the known flagship family first — the+ # rescue pick must equal the top row of the vision-filtered dropdown.+ assert pick_vision_model("openrouter") == "anthropic/claude-sonnet-5"+++def test_media_generation_models_are_not_picked(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {+ "id": "google/gemini-3-pro-image",+ "input_modalities": ["image", "text"],+ "output_modalities": ["image"],+ },+ ])+ # Accepts images but GENERATES images -> not a brain; nothing to pick.+ assert pick_vision_model("openrouter") is None+++def test_no_modality_data_returns_none(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [{"id": "gemini-3.5-flash"}], provider="gemini")+ assert pick_vision_model("gemini") is None+++def test_missing_cache_returns_none(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ assert pick_vision_model("openrouter") is None+++# ---------------------------------------------------------------------------+# CU chain rescue+# ---------------------------------------------------------------------------++def test_chain_swaps_blind_model_for_vision_sibling(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {"id": "deepseek/deepseek-v4-flash", "input_modalities": ["text"]},+ {"id": "qwen/qwen3-vl", "input_modalities": ["text", "image"]},+ ])+ chain = [("openrouter", "deepseek/deepseek-v4-flash")]+ assert _rescue_blind_models(chain) == [("openrouter", "qwen/qwen3-vl")]+++def test_chain_keeps_vision_and_unknown_models(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {"id": "x/multi", "input_modalities": ["text", "image"]},+ ])+ chain = [+ ("openrouter", "x/multi"), # vision True -> untouched+ ("gemini", "gemini-3.5-flash"), # unknown -> untouched+ ("claude-api", None), # no explicit model -> untouched+ ]+ assert _rescue_blind_models(chain) == chain+++def test_chain_keeps_blind_model_when_no_sibling_exists(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, [+ {"id": "x/text-a", "input_modalities": ["text"]},+ {"id": "x/text-b", "input_modalities": ["text"]},+ ])+ chain = [("openrouter", "x/text-a")]+ # No vision sibling -> unchanged; the selector's blind-skip handles it.+ assert _rescue_blind_models(chain) == chain