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): honour the canonical Tool Model selection as an explicit pin
Ruben Lütke77b5abab7b52
diff --git a/jarvis/cu/brain_call.py b/jarvis/cu/brain_call.pyindex d33803f862..399e512d30 100644--- a/jarvis/cu/brain_call.py+++ b/jarvis/cu/brain_call.py@@ -67,7 +67,16 @@ def _log_serving(provider: str, model: str | None) -> None:def _explicit_cu_pin(manager: Any, provider: str) -> str | None:- """The user's RAW ``cu_model`` config pin for ``provider``, or ``None``.+ """The user's RAW Tool Model pin for ``provider``, or ``None``.++ Reads the CANONICAL ``tool_model`` field first, then the legacy+ ``cu_model`` — both are the user's explicit word and must never be+ second-guessed by the speed tune. Reading only ``cu_model`` here was a+ live defect (2026-07-16): the Tool Model tab persists ``tool_model``+ only, so after a restart the selection stopped counting as a pin and+ the speed tune silently swapped the user's chosen model for the fast+ vision sibling — the selection then applied to realtime delegation but+ not to Computer-Use.Deliberately NOT ``manager._cu_model`` — that resolver falls back to themain model / tier default and therefore never returns ``None``, which@@ -76,7 +85,7 @@ def _explicit_cu_pin(manager: Any, provider: str) -> str | None:try:provider_cfg = getattr(manager, "_provider_cfg", None)cfg = provider_cfg(provider) if callable(provider_cfg) else None- pin = getattr(cfg, "cu_model", None)+ pin = getattr(cfg, "tool_model", None) or getattr(cfg, "cu_model", None)return str(pin) if pin else Noneexcept Exception: # noqa: BLE001return Nonediff --git a/tests/unit/cu/test_brain_call_cu_provider.py b/tests/unit/cu/test_brain_call_cu_provider.pyindex 97be5a1820..2866eeb20b 100644--- a/tests/unit/cu/test_brain_call_cu_provider.py+++ b/tests/unit/cu/test_brain_call_cu_provider.py@@ -162,6 +162,103 @@ async def test_blind_cu_provider_falls_back_through_vision_gate() -> None:assert manager.brains["claude-api"].calls == 0+class _ProviderCfg:+ """Shape of ``BrainProviderConfig`` for the pin-resolution surface."""++ def __init__(+ self,+ *,+ tool_model: str | None = None,+ cu_model: str | None = None,+ model: str | None = None,+ ) -> None:+ self.tool_model = tool_model+ self.cu_model = cu_model+ self.model = model+++class _PinAwareManager(_FakeManager):+ """FakeManager with a realistic per-provider config + Tool Model resolver.++ ``_cu_model`` mirrors the real ``BrainManager._tool_model_model``:+ ``tool_model`` → ``cu_model`` → main ``model`` → None. ``_provider_cfg``+ exposes the RAW config the pin detector reads.+ """++ def __init__(self, pins: dict[str, _ProviderCfg]) -> None:+ super().__init__(cu_provider="")+ self._pins = pins++ def _provider_cfg(self, name: str) -> _ProviderCfg | None:+ return self._pins.get(name)++ def _cu_model(self, name: str) -> str | None:+ cfg = self._pins.get(name)+ if cfg is None:+ return None+ return cfg.tool_model or cfg.cu_model or cfg.model+++def _patch_speed_tune_catalog(monkeypatch) -> None:+ """Make the speed tune deterministic: every provider has a known fast+ vision sibling, and no configured model counts as fast-class."""+ import jarvis.brain.model_catalog as catalog++ monkeypatch.setattr(catalog, "model_capabilities", lambda p, m: {})+ monkeypatch.setattr(catalog, "is_fast_class_model", lambda m: False)+ monkeypatch.setattr(+ catalog, "pick_fast_vision_model", lambda p: "fast-vision-sibling"+ )+ monkeypatch.setattr(catalog, "provider_has_modality_data", lambda p: True)+++async def test_canonical_tool_model_selection_is_a_pin_cu_must_not_swap(+ monkeypatch,+) -> None:+ """THE 2026-07-16 defect: the Tool Model tab persists only the canonical+ ``tool_model`` key, so after a restart the user's explicit selection+ (e.g. Claude Fable 5) no longer counted as a pin and the speed tune+ silently swapped it for the fast vision sibling — Computer-Use then ran+ on a model the user never chose, while realtime delegation honoured the+ selection. The canonical key must pin exactly like the legacy one."""+ _patch_speed_tune_catalog(monkeypatch)+ manager = _PinAwareManager(+ {"brain-primary": _ProviderCfg(tool_model="claude-fable-5")}+ )+ img = ImageBlock(mime="image/jpeg", data_b64="QQ==", source_hash="x")++ await call_vision_brain(manager, build_prompt=_build_prompt, images=[img])++ assert manager.requested[0] == ("brain-primary", "claude-fable-5")+++async def test_legacy_cu_model_pin_still_wins(monkeypatch) -> None:+ """Old installations pin via ``cu_model`` only — that word still counts."""+ _patch_speed_tune_catalog(monkeypatch)+ manager = _PinAwareManager(+ {"brain-primary": _ProviderCfg(cu_model="my-legacy-cu-model")}+ )+ img = ImageBlock(mime="image/jpeg", data_b64="QQ==", source_hash="x")++ await call_vision_brain(manager, build_prompt=_build_prompt, images=[img])++ assert manager.requested[0] == ("brain-primary", "my-legacy-cu-model")+++async def test_unpinned_provider_still_gets_speed_tuned(monkeypatch) -> None:+ """No explicit Tool Model selection → the speed tune keeps swapping the+ slow main model for the fast vision sibling (existing behavior)."""+ _patch_speed_tune_catalog(monkeypatch)+ manager = _PinAwareManager(+ {"brain-primary": _ProviderCfg(model="slow-flagship-chat-model")}+ )+ img = ImageBlock(mime="image/jpeg", data_b64="QQ==", source_hash="x")++ await call_vision_brain(manager, build_prompt=_build_prompt, images=[img])++ assert manager.requested[0] == ("brain-primary", "fast-vision-sibling")++async def test_serving_brain_logged_once_per_identity(caplog) -> None:"""The provider that ACTUALLY serves is logged — once per identity change.