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
fix(cu): speed tune was silently disabled by pin misdetection + gemini substring bug
Ruben Lütkeaafb1d72e273
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.pyindex 0a4f597752..6d9878f17a 100644--- a/jarvis/brain/model_catalog.py+++ b/jarvis/brain/model_catalog.py@@ -381,6 +381,37 @@ _FAST_CLASS_MARKERS: tuple[str, ...] = ()+def provider_has_modality_data(provider: str) -> bool:+ """True when the cached catalog carries ``input_modalities`` for at least+ one of ``provider``'s models — i.e. a "no vision model found" verdict is+ an informed NO, not missing data. Direct provider endpoints (gemini /+ claude-api / openai) expose no modality metadata and return False."""+ 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"))+ return any(+ isinstance(m.get("input_modalities"), list)+ for m in data.get(provider, {}).get("models", [])+ )+ except Exception: # noqa: BLE001+ return False+++def is_fast_class_model(model_id: str | None) -> bool:+ """True when the model id names a low-latency sibling (fast class).++ Markers match WHOLE id tokens (split on non-alphanumerics), never raw+ substrings — "mini" as a substring matches every "ge**mini**" model and+ classified Gemini PRO as fast (live bug 2026-07-02).+ """+ if not model_id:+ return False+ tokens = set(re.split(r"[^a-z0-9]+", model_id.lower()))+ return any(mark in tokens for mark in _FAST_CLASS_MARKERS)++def pick_fast_vision_model(provider: str) -> str | None:"""The best FAST vision-capable model of ``provider`` (or ``None``).@@ -419,8 +450,7 @@ def pick_fast_vision_model(provider: str) -> str | None:# Fast class first — but only KNOWN families (family rank > 0), so an# obscure "-mini" of an unknown vendor never beats a Gemini Flash / Haiku.for m in usable:- low = m.id.lower()- if _family_rank(m.id) > 0 and any(mark in low for mark in _FAST_CLASS_MARKERS):+ if _family_rank(m.id) > 0 and is_fast_class_model(m.id):return m.idreturn usable[0].iddiff --git a/jarvis/cu/brain_call.py b/jarvis/cu/brain_call.pyindex 3611bc9c9e..6ecaeef3eb 100644--- a/jarvis/cu/brain_call.py+++ b/jarvis/cu/brain_call.py@@ -92,8 +92,10 @@ def _speed_tune_chain("""try:from jarvis.brain.model_catalog import ( # noqa: PLC0415+ is_fast_class_model,model_capabilities,pick_fast_vision_model,+ provider_has_modality_data,)except Exception: # noqa: BLE001return chain@@ -105,13 +107,20 @@ def _speed_tune_chain(try:caps = model_capabilities(provider, model) if model else {}blind = caps.get("vision") is False+ if not blind and is_fast_class_model(model):+ # The configured model is already the fast class (and not+ # known-blind) — keep the user's choice untouched.+ tuned.append((provider, model))+ continuealt = pick_fast_vision_model(provider)- if alt is None:+ if alt is None and not provider_has_modality_data(provider):# Direct provider endpoints expose no modality metadata, so- # the catalog pick is empty — fall back to the provider's- # curated router-tier (fast) default, unless it is known- # blind. Keeps "steps run on the fast class" true for EVERY- # key, not only catalog-backed gateways.+ # the empty catalog pick means "no data", not "no vision+ # model" — fall back to the provider's curated router-tier+ # (fast) default. Keeps "steps run on the fast class" true+ # for EVERY key, not only catalog-backed gateways. When the+ # catalog HAS data and found nothing, there is genuinely no+ # vision model to offer — no blind guessing.try:from jarvis.brain.manager import ( # noqa: PLC0415get_tier_default_model,diff --git a/tests/unit/brain/test_pick_vision_model.py b/tests/unit/brain/test_pick_vision_model.pyindex 9a941227ab..3148511276 100644--- a/tests/unit/brain/test_pick_vision_model.py+++ b/tests/unit/brain/test_pick_vision_model.py@@ -145,3 +145,45 @@ def test_chain_respects_an_explicit_cu_pin(monkeypatch, tmp_path):chain = [("openrouter", "anthropic/claude-opus-4.8")]# The user pinned this model for CU — never second-guess it.assert _speed_tune_chain(chain, pinned={"openrouter"}) == chain+++def test_chain_keeps_an_already_fast_model(monkeypatch, tmp_path):+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path)+ _write_cache(tmp_path, _FAST_CATALOG)+ chain = [("openrouter", "google/gemini-3.5-flash")]+ assert _speed_tune_chain(chain) == chain+++def test_direct_provider_flagship_falls_back_to_router_tier_default(+ monkeypatch, tmp_path,+):+ # Direct endpoints (gemini/claude-api) expose no modality metadata, so the+ # catalog pick is empty — the provider's curated router-tier default takes+ # over for the mission steps.+ monkeypatch.setattr(cfg, "DATA_DIR", tmp_path) # no catalog cache at all+ from jarvis.brain.manager import get_tier_default_model++ expected = get_tier_default_model("router", "gemini")+ assert expected, "router-tier default for gemini must exist"+ chain = [("gemini", "gemini-3-pro")]+ assert _speed_tune_chain(chain) == [("gemini", expected)]+++def test_explicit_pin_detection_reads_raw_config_field():+ from types import SimpleNamespace++ from jarvis.cu.brain_call import _explicit_cu_pin++ class FakeManager:+ def __init__(self, cu_model, model):+ self._cfg = SimpleNamespace(cu_model=cu_model, model=model)++ def _provider_cfg(self, name):+ return self._cfg++ # Only the RAW cu_model field counts as a pin — a configured main model+ # must NOT (the resolver falls back to it, which previously made every+ # provider look pinned and disabled the speed tune).+ assert _explicit_cu_pin(FakeManager("x/pinned", "x/main"), "p") == "x/pinned"+ assert _explicit_cu_pin(FakeManager(None, "x/main"), "p") is None+ assert _explicit_cu_pin(FakeManager("", "x/main"), "p") is None