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
perf(agentic-ide): the brief writer answers soonest — Tool Model, API tier, then the coding CLI
Haraldbd2d785bd647
diff --git a/jarvis/agentic_ide/writer.py b/jarvis/agentic_ide/writer.pyindex 71294f0f7e..f707f9f121 100644--- a/jarvis/agentic_ide/writer.py+++ b/jarvis/agentic_ide/writer.py@@ -17,8 +17,23 @@ The order, and why each rung is where it is:tab, for work the assistant does on its own behalf. It resolves through``resolve_tool_model_brain`` and nowhere else: a Tool Model pin that quietlylanded on a coding CLI would make the setting meaningless.-3. **``auto`` prefers a connected subscription**, because it is work the user- has already paid for, then crosses to the API tier if none answers.+3. **``auto`` prefers the writer that answers soonest**: the pinned Tool+ Model first, then the API-billed quality tier, then a connected coding+ subscription. A brief written for a SPOKEN instruction sits on the voice+ turn's critical path — the user is standing there, waiting for the text to+ land in the pane — and a subscription CLI pays a cold process start before+ it thinks at all. Measured live 2026-08-18 16:10: the CLI wrote a 1248-char+ brief in 18.9 s, nearly all of it the spawn (an EMPTY answer from the same+ CLI took 17-19 s in the same minute, against 5-6 s an hour earlier — the+ start-up cost triples under load), while the Tool Model on the same box+ wrote the same brief in 5 s warm. Until 2026-08-18 ``auto`` put the subscription+ first because it is work the user has already paid for; it now writes under+ ``auto`` only when nothing API-side qualifies — an install whose ONLY+ credential is a coding CLI still gets its brief — and a user who wants the+ plan spent on purpose pins ``subscription``. The Tool Model rung leads+ because it is, by the Tool Model tab's own words, the model that "routes+ spoken commands and starts background agents": a spoken instruction to a+ pane is exactly that work.4. **Nothing qualifies → ``(None, "")``**, and the caller says so.The distinction users actually make here is "an API key I pay per token for"@@ -173,27 +188,54 @@ def _resolve_writer_uncached(*, cli_timeout_s: float | None) -> tuple[Any | Noneif choice == "tool_model":return _tool_model_writer(config)+ if choice == "auto":+ return _fastest_writer(config, cli_timeout_s)+subscription = _try_subscription(config, cli_timeout_s)if subscription is not None:name = getattr(subscription, "name", None) or choicereturn subscription, f"subscription:{name}"- if choice != "auto":- # An explicit pin that cannot be honoured degrades openly rather than- # quietly billing a key the user did not choose.- logger.info(- "Agentic IDE writer pinned to '{}' but it is unreachable — using the "- "deterministic prompt rather than silently billing another provider",- choice,- )- return None, ""+ # An explicit pin that cannot be honoured degrades openly rather than+ # quietly billing a key the user did not choose.+ logger.info(+ "Agentic IDE writer pinned to '{}' but it is unreachable — using the "+ "deterministic prompt rather than silently billing another provider",+ choice,+ )+ return None, ""++# The ``auto`` order — and the order a dead call crosses over in. ONE tuple for+# both on purpose: "who writes" and "who rescues" must never drift apart, and+# both answer the same question the same way — which reachable writer delivers+# the brief soonest without a demotion in quality. Direct API calls (the Tool+# Model and the quality tier) have no process to cold-start; the subscription+# CLI pays 5-19 s of spawn per brief (measured 2026-08-18, see the module+# docstring) and therefore goes last in BOTH orders — the writer of last resort+# under ``auto``, and the last rescue after a failed one.+_AUTO_ORDER = ("tool_model", "api", "subscription")+++def _writer_for_rung(rung: str, config: Any, cli_timeout_s: float | None) -> tuple[Any | None, str]:+ """One rung of :data:`_AUTO_ORDER` resolved, or ``(None, "")``."""+ if rung == "tool_model":+ return _tool_model_writer(config, pinned=False)+ if rung == "subscription":+ brain = _try_subscription(config, cli_timeout_s)+ if brain is None:+ return None, ""+ return brain, f"subscription:{getattr(brain, 'name', None) or 'subscription'}"return _api_writer(config)-# The rungs a dead call may cross to, best first. Deliberately the same three-# the pins name, so "who writes" and "who rescues" can never drift apart.-_RESCUE_ORDER = ("tool_model", "subscription", "api")+def _fastest_writer(config: Any, cli_timeout_s: float | None) -> tuple[Any | None, str]:+ """The ``auto`` answer: the first rung of :data:`_AUTO_ORDER` that qualifies."""+ for rung in _AUTO_ORDER:+ brain, source = _writer_for_rung(rung, config, cli_timeout_s)+ if brain is not None:+ return brain, source+ return None, ""def resolve_rescue_writer(@@ -221,16 +263,10 @@ def resolve_rescue_writer(logger.info("Agentic IDE rescue writer could not be resolved", exc_info=True)return None, ""- for rung in _RESCUE_ORDER:+ for rung in _AUTO_ORDER:if rung in tried:continue- if rung == "tool_model":- brain, source = _tool_model_writer(config)- elif rung == "subscription":- brain = _try_subscription(config, cli_timeout_s)- source = f"subscription:{getattr(brain, 'name', None) or 'subscription'}"- else:- brain, source = _api_writer(config)+ brain, source = _writer_for_rung(rung, config, cli_timeout_s)if brain is not None:logger.info("Agentic IDE brief falls across to {} after a failed writer", source)return brain, source@@ -256,7 +292,7 @@ def _api_writer(config: Any) -> tuple[Any | None, str]:return (brain, "api") if brain is not None else (None, "")-def _tool_model_writer(config: Any) -> tuple[Any | None, str]:+def _tool_model_writer(config: Any, *, pinned: bool = True) -> tuple[Any | None, str]:"""The user's configured Tool Model, or ``(None, "")``.Does NOT fall through to the quality tier when the Tool Model is unset or@@ -265,6 +301,10 @@ def _tool_model_writer(config: Any) -> tuple[Any | None, str]:written by a coding CLI would be no better off if it silently landed on athird model instead. The caller degrades to its deterministic prompt andreports that honestly.++ ``pinned=False`` is the ``auto`` order asking: there an unset Tool Model is+ the ordinary case and the next rung answers, so it earns no log line that+ reads like a broken pin."""try:brain = _tool_model(config)@@ -272,11 +312,12 @@ def _tool_model_writer(config: Any) -> tuple[Any | None, str]:logger.info("Agentic IDE tool-model writer unavailable", exc_info=True)return None, ""if brain is None:- logger.info(- "Agentic IDE writer pinned to the Tool Model, but no usable Tool "- "Model is configured — using the deterministic prompt rather than "- "silently writing with another model"- )+ if pinned:+ logger.info(+ "Agentic IDE writer pinned to the Tool Model, but no usable Tool "+ "Model is configured — using the deterministic prompt rather than "+ "silently writing with another model"+ )return None, ""name = getattr(brain, "name", None) or "tool model"return brain, f"tool_model:{name}"diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex 76d733ab1f..fd5f3f2d63 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -3534,8 +3534,9 @@ class AgenticIdeConfig(BaseModel):prompt_writer: str = Field(default="auto",description=(- "Who writes Agentic IDE task briefs: 'auto' (a connected coding "- "subscription if there is one, else the API-billed quality tier), "+ "Who writes Agentic IDE task briefs: 'auto' (the writer that answers "+ "soonest — your Tool Model if one is pinned, else the API-billed "+ "quality tier, else a connected coding subscription), 'tool_model', ""'subscription', 'api', or a specific brain provider id."),)diff --git a/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx b/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsxindex c9fcf7f296..638cf29bc0 100644--- a/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx+++ b/jarvis/ui/web/frontend/src/components/PromptWriterCard.test.tsx@@ -26,7 +26,7 @@ const mockSave = vi.mocked(savePromptWriter);const STATE = {prompt_writer: "auto",options: [- { id: "auto", label: "Automatic (a connected subscription, else the API model)", connected: true },+ { id: "auto", label: "Automatic (your Tool Model, else the API model, else a connected subscription)", connected: true },{ id: "tool_model", label: "Tool Model (Google Gemini - gemini-3.6-flash)", connected: true },{ id: "subscription", label: "Any connected coding CLI (never an API key)", connected: true },{ id: "api", label: "API model (billed per token)", connected: true },diff --git a/tests/unit/agentic_ide/test_writer_cache.py b/tests/unit/agentic_ide/test_writer_cache.pyindex 3f38f44e94..fa63b28c7c 100644--- a/tests/unit/agentic_ide/test_writer_cache.py+++ b/tests/unit/agentic_ide/test_writer_cache.py@@ -19,17 +19,29 @@ def _cfg(choice: str) -> SimpleNamespace:return SimpleNamespace(agentic_ide=SimpleNamespace(prompt_writer=choice))[email protected](autouse=True)+def _only_the_subscription_qualifies(monkeypatch: pytest.MonkeyPatch) -> None:+ """These tests are about the CACHE, not the order: the API-side rungs that+ ``auto`` now tries first are unset, so the subscription probe is the one+ resolution whose repeats and misses are counted."""+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: None)++def test_a_success_is_reused_within_the_ttl(monkeypatch: pytest.MonkeyPatch) -> None:loads: list[int] = []monkeypatch.setattr(writer, "_load_config", lambda: loads.append(1) or _cfg("auto"))- monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: "sub-brain")+ monkeypatch.setattr(+ writer, "_subscription", lambda cfg, timeout: SimpleNamespace(name="claude-cli")+ )first = writer.resolve_writer(cli_timeout_s=90.0)second = writer.resolve_writer(cli_timeout_s=90.0)- assert first == second == ("sub-brain", "subscription:auto")+ assert first == second+ assert first[1] == "subscription:claude-cli"assert len(loads) == 1@@ -73,10 +85,9 @@ def test_a_rescue_resolution_invalidates_the_cache()monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: "sub-brain")monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")- monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)writer.resolve_writer()- writer.resolve_rescue_writer(exclude=("subscription:auto",))+ writer.resolve_rescue_writer(exclude=("api",))writer.resolve_writer()# Three real resolutions: the second resolve_writer re-asked.diff --git a/tests/unit/agentic_ide/test_writer_rescue.py b/tests/unit/agentic_ide/test_writer_rescue.pyindex 04780debcf..5e6bca852d 100644--- a/tests/unit/agentic_ide/test_writer_rescue.py+++ b/tests/unit/agentic_ide/test_writer_rescue.py@@ -35,7 +35,9 @@ def test_a_dead_api_tier_crosses_to_the_tool_model(monkeypatch: pytest.MonkeyPatdef test_the_rung_that_died_is_never_retried(monkeypatch: pytest.MonkeyPatch) -> None:- """Re-probing the same tier spends the same dead credential twice."""+ """Re-probing the same tier spends the same dead credential twice — and the+ rescue crosses in the ``auto`` order, so a dead Tool Model is followed by+ the API tier (no cold start), the coding CLI last."""monkeypatch.setattr(writer, "_load_config", lambda: _cfg())monkeypatch.setattr(writer, "_tool_model", lambda cfg: "tool-brain")monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: "sub-brain")@@ -43,8 +45,34 @@ def test_the_rung_that_died_is_never_retried(monkeypatch: pytest.MonkeyPatch) ->brain, source = writer.resolve_rescue_writer(exclude=("tool_model:grok",))- assert brain == "sub-brain"- assert source.startswith("subscription")+ assert brain == "api-brain"+ assert source == "api"+++def test_the_subscription_is_the_last_rescue(monkeypatch: pytest.MonkeyPatch) -> None:+ """Both API-side rungs dead: only now is a coding CLI's cold start worth+ paying — the user is still waiting, and a rescue that starts on the slowest+ writer while a faster one qualifies is the same delay wearing a new name."""+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg())+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: "tool-brain")+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: SimpleNamespace(name="codex"))+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_rescue_writer(exclude=("tool_model:grok", "api"))++ assert getattr(brain, "name", "") == "codex"+ assert source == "subscription:codex"+++def test_rescue_and_first_choice_share_one_order() -> None:+ """The drift guard: "who writes" and "who rescues" answer the same question+ from ONE tuple, so a rung can never be first choice in one and forgotten in+ the other."""+ import inspect++ assert writer._AUTO_ORDER == ("tool_model", "api", "subscription") # noqa: SLF001+ for function in (writer._fastest_writer, writer.resolve_rescue_writer): # noqa: SLF001+ assert "_AUTO_ORDER" in inspect.getsource(function)def test_a_named_source_is_compared_by_its_rung(monkeypatch: pytest.MonkeyPatch) -> None:@@ -107,6 +135,7 @@ def test_the_cli_timeout_reaches_the_subscription_probe(seen: list[float | None] = []monkeypatch.setattr(writer, "_load_config", lambda: _cfg())monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: None)monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: seen.append(timeout) or "sub-brain")diff --git a/tests/unit/agentic_ide/test_writer_resolution.py b/tests/unit/agentic_ide/test_writer_resolution.pyindex b848714c67..b8f16ad2ba 100644--- a/tests/unit/agentic_ide/test_writer_resolution.py+++ b/tests/unit/agentic_ide/test_writer_resolution.py@@ -17,21 +17,38 @@ def _cfg(choice: str) -> SimpleNamespace:return SimpleNamespace(agentic_ide=SimpleNamespace(prompt_writer=choice))-def test_auto_prefers_a_connected_subscription(monkeypatch: pytest.MonkeyPatch) -> None:+def test_auto_prefers_the_pinned_tool_model(monkeypatch: pytest.MonkeyPatch) -> None:+ """The live 2026-08-18 16:10 delay: ``auto`` handed a spoken instruction to+ the subscription CLI, which spent 18.9 s — nearly all of it its own process+ start — while the user's Tool Model would have written the same brief in+ 1-3 s. Under ``auto`` the writer that answers soonest goes first, and a+ slower rung is not even probed while a faster one qualifies."""monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))- monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: "sub-brain")+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: SimpleNamespace(name="vertex"))monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")+ monkeypatch.setattr(+ writer,+ "_subscription",+ lambda cfg, timeout: pytest.fail("probed a coding CLI while a faster writer qualified"),+ )brain, source = writer.resolve_writer()- assert brain == "sub-brain"- assert source.startswith("subscription")+ assert getattr(brain, "name", "") == "vertex"+ assert source == "tool_model:vertex"-def test_auto_falls_through_to_the_api_tier(monkeypatch: pytest.MonkeyPatch) -> None:+def test_auto_prefers_the_api_tier_over_a_subscription(monkeypatch: pytest.MonkeyPatch) -> None:+ """No Tool Model pinned: a direct API call has no cold start to pay, so it+ writes before any coding CLI is asked."""monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))- monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: None)+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")+ monkeypatch.setattr(+ writer,+ "_subscription",+ lambda cfg, timeout: pytest.fail("probed a coding CLI while a faster writer qualified"),+ )brain, source = writer.resolve_writer()@@ -39,6 +56,41 @@ def test_auto_falls_through_to_the_api_tier(monkeypatch: pytest.MonkeyPatch) ->assert source == "api"+def test_auto_reaches_the_subscription_when_nothing_api_side_qualifies(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """The downloader whose ONLY credential is a coding CLI still gets a+ written brief — the subscription is last, not gone."""+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: None)+ monkeypatch.setattr(+ writer, "_subscription", lambda cfg, timeout: SimpleNamespace(name="claude-cli")+ )++ brain, source = writer.resolve_writer()++ assert getattr(brain, "name", "") == "claude-cli"+ assert source == "subscription:claude-cli"+++def test_an_unset_tool_model_is_the_ordinary_auto_case(monkeypatch: pytest.MonkeyPatch) -> None:+ """Under ``auto`` a missing Tool Model is not a broken pin: the next rung+ answers, and the log stays free of a "pinned to the Tool Model" complaint+ that would send the user to a setting they never touched."""+ seen: list[str] = []+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: None)+ monkeypatch.setattr(writer.logger, "info", lambda msg, *a, **k: seen.append(str(msg)))++ brain, _source = writer.resolve_writer()++ assert brain == "api-brain"+ assert not [line for line in seen if "pinned to the Tool Model" in line]++def test_api_pin_never_reaches_a_subscription(monkeypatch: pytest.MonkeyPatch) -> None:"""A user who pinned 'api' must not have their plan quota spent behind theirback — the mirror image of the billing surprise this feature removes."""@@ -93,6 +145,7 @@ def test_the_timeout_reaches_the_subscription_resolver(still willing to wait for."""seen: list[float | None] = []monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: seen.append(timeout) or "sub")@@ -114,22 +167,21 @@ def test_resolution_never_raises(monkeypatch: pytest.MonkeyPatch) -> None:assert writer.resolve_writer() == (None, "")-def test_a_failing_subscription_resolver_still_reaches_the_api_tier(+def test_a_raising_subscription_probe_degrades_instead_of_raising(monkeypatch: pytest.MonkeyPatch,) -> None:- """A broken CLI probe must not cost the user their working API path."""+ """A broken CLI probe is the last rung's problem alone: it must neither+ reach the caller nor be mistaken for a writer."""def _boom(cfg: object, timeout: object) -> object:raise RuntimeError("cli probe exploded")monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: None)monkeypatch.setattr(writer, "_subscription", _boom)- monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")- brain, source = writer.resolve_writer()-- assert brain == "api-brain"- assert source == "api"+ assert writer.resolve_writer() == (None, "")def test_both_call_sites_use_this_module() -> None: