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(agentic-ide): write briefs and splits on a connected subscription
Ruben Lütke745854c2f14c
diff --git a/jarvis/agentic_ide/prompt_composer.py b/jarvis/agentic_ide/prompt_composer.pyindex 4d2005b1e9..a5fd65c067 100644--- a/jarvis/agentic_ide/prompt_composer.py+++ b/jarvis/agentic_ide/prompt_composer.py@@ -79,7 +79,13 @@ from .session import MAX_PROMPT_CHARS, sanitize_prompt# mid-composition does not produce a faster good prompt, it produces the regex# one — which 8 s did routinely and 20 s still did for the longest brief. The# ceiling is therefore well clear of the measured worst case.-COMPOSE_TIMEOUT_S = 45.0+#+# Raised 45 → 90 s when the writer gained a subscription-CLI path (2026-07-26).+# Those brains pay a cold process start before they think at all: measured+# 10-12 s for a trivial prompt and 26.6 s for a real structured brief on the+# fastest model. At 45 s a slower model or a loaded machine would have expired+# routinely, and every expiry buys the regex prompt — never a faster good one.+COMPOSE_TIMEOUT_S = 90.0# How many files may be attached. Enough to point the agent at a feature's# surface; few enough that the agent's context is not flooded with guesses.@@ -186,22 +192,22 @@ def _extract_referenced(text: str) -> list[str]:def _resolve_writer(): # noqa: ANN202 - Brain | None, avoid an import cycle- """The model that writes prompts, or None when only fast tiers are up.+ """The model that writes prompts, or None when nothing qualifies.++ Delegates to ``writer.resolve_writer`` so this decision lives in ONE place:+ the work splitter makes the same choice, and a user who moved briefs onto a+ subscription must not find the split still billing an API key.- Uses ``resolve_quality_brain`` rather than the full frontier chain: the- latter is built so a core path never dies and therefore ends in small, fast- models. Here the OUTPUT is the product, and a brief written by a mini model- is worse in a way nobody notices — it reads perfectly well. Returning None- lets the caller degrade to the deterministic prompt and say so.+ Neither rung of that order is the full frontier chain. That chain is built+ so a core path never dies and therefore ends in small, fast models; here the+ OUTPUT is the product, and a brief written by a mini model is worse in a way+ nobody notices — it reads perfectly well. Returning None lets the caller+ degrade to the deterministic prompt and say so."""- from jarvis.brain.resolver import resolve_quality_brain- from jarvis.core.config import load_config+ from .writer import resolve_writer- try:- return resolve_quality_brain(load_config())- except Exception: # noqa: BLE001 - resolution must never break a turn- logger.info("Agentic IDE prompt writer could not be resolved", exc_info=True)- return None+ brain, _source = resolve_writer(cli_timeout_s=COMPOSE_TIMEOUT_S)+ return brain# How much of the repository's agent instructions to carry. Enough for thediff --git a/jarvis/agentic_ide/work_split.py b/jarvis/agentic_ide/work_split.pyindex b5fcb106ae..50d7010edf 100644--- a/jarvis/agentic_ide/work_split.py+++ b/jarvis/agentic_ide/work_split.py@@ -42,10 +42,19 @@ from typing import Anyfrom loguru import logger-#: Bound for the one splitting call. Shorter than the composer's: this produces-#: a short JSON plan rather than a full brief, and it runs BEFORE any prompt is-#: composed — every second here is a second added in front of N compositions.-SPLIT_TIMEOUT_S = 25.0+#: Bound for the one splitting call. Still shorter than the composer's: this+#: produces a short JSON plan rather than a full brief, and it runs BEFORE any+#: prompt is composed — every second here is a second added in front of N+#: compositions.+#:+#: Raised 25 → 60 s when the writer gained a subscription-CLI path (2026-07-26).+#: Those brains pay a cold process start of 10-12 s before thinking at all, so a+#: 25 s bound expired on essentially every subscription split — and an expiry+#: here is not a slower split, it is the crude by-directory one. Silently+#: shipping that while the user believes a model planned the fan-out is exactly+#: the invisible degradation this module's own docstring warns about. The bound+#: is a reprieve, not a target: a healthy split still returns in a few seconds.+SPLIT_TIMEOUT_S = 60.0#: A fleet larger than this is not a split any model plans usefully, and the#: deterministic layer runs out of real directories long before it. Above the@@ -84,15 +93,16 @@ class WorkSplit:def _resolve_splitter() -> Any:- """The model that plans a split, or None when only fast tiers are up."""- from jarvis.brain.resolver import resolve_quality_brain- from jarvis.core.config import load_config+ """The model that plans a split, or None when nothing qualifies.- try:- return resolve_quality_brain(load_config())- except Exception: # noqa: BLE001 - resolution must never break a turn- logger.info("Agentic IDE work splitter could not be resolved", exc_info=True)- return None+ Shares ``writer.resolve_writer`` with the prompt composer on purpose: these+ two are the Agentic IDE's only billed calls, and a user who moved briefs+ onto their subscription must not find the split still charging an API key.+ """+ from .writer import resolve_writer++ brain, _source = resolve_writer(cli_timeout_s=SPLIT_TIMEOUT_S)+ return brain_SYSTEM_PROMPT = (diff --git a/jarvis/agentic_ide/writer.py b/jarvis/agentic_ide/writer.pynew file mode 100644index 0000000000..a566fdf3b2--- /dev/null+++ b/jarvis/agentic_ide/writer.py@@ -0,0 +1,108 @@+"""Who writes an Agentic IDE brief — one order, both call sites.++The prompt composer and the work splitter each used to carry their own copy of+this decision. They must never diverge: a user who moves briefs onto their+subscription and then finds the splitter still billing an API key has been told+one thing and charged for another.++The order, and why each rung is where it is:++1. **A pin is a pin.** ``api`` never touches a subscription — a user who chose+ the API tier must not have their plan quota spent behind their back — and a+ named provider or ``subscription`` never quietly falls back to the API key,+ which is the same surprise in the other direction. An unhonourable pin+ degrades to the caller's deterministic layer, which is at least honest.+2. **``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. **Nothing qualifies → ``(None, "")``**, and the caller says so.++Never raises. Every failure here costs a rougher prompt; none of them may cost+the user their instruction.+"""+from __future__ import annotations++from typing import Any++from loguru import logger+++def _load_config() -> Any:+ from jarvis.core.config import load_config++ return load_config()+++def _subscription(config: Any, cli_timeout_s: float | None) -> Any:+ from jarvis.brain.resolver import resolve_subscription_brain++ return resolve_subscription_brain(config, cli_timeout_s=cli_timeout_s)+++def _quality(config: Any) -> Any:+ from jarvis.brain.resolver import resolve_quality_brain++ return resolve_quality_brain(config)+++def _configured_choice(config: Any) -> str:+ raw = getattr(getattr(config, "agentic_ide", None), "prompt_writer", "auto")+ return str(raw or "auto").strip() or "auto"+++def resolve_writer(*, cli_timeout_s: float | None = None) -> tuple[Any | None, str]:+ """The brain that writes the brief, and where it came from.++ ``cli_timeout_s`` is the caller's own budget, forwarded so a CLI brain's+ internal voice-tier cap cannot kill a call the caller is still waiting on.++ Returns ``(None, "")`` whenever nothing qualifies — the caller then uses its+ deterministic layer and reports that honestly.+ """+ try:+ config = _load_config()+ choice = _configured_choice(config)+ except Exception: # noqa: BLE001 - resolution must never break a turn+ logger.info("Agentic IDE writer could not be resolved", exc_info=True)+ return None, ""++ if choice == "api":+ return _api_writer(config)++ subscription = _try_subscription(config, cli_timeout_s)+ if subscription is not None:+ name = getattr(subscription, "name", None) or choice+ return 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, ""++ return _api_writer(config)+++def _try_subscription(config: Any, cli_timeout_s: float | None) -> Any | None:+ """A connected subscription brain, or None. A failure here is not fatal."""+ try:+ return _subscription(config, cli_timeout_s)+ except Exception: # noqa: BLE001 - a broken CLI probe must not cost the API path+ logger.info("Agentic IDE subscription writer unavailable", exc_info=True)+ return None+++def _api_writer(config: Any) -> tuple[Any | None, str]:+ """The API-billed quality tier, or ``(None, "")``."""+ try:+ brain = _quality(config)+ except Exception: # noqa: BLE001+ logger.info("Agentic IDE quality writer unavailable", exc_info=True)+ return None, ""+ return (brain, "api") if brain is not None else (None, "")+++__all__ = ["resolve_writer"]diff --git a/tests/unit/agentic_ide/test_writer_resolution.py b/tests/unit/agentic_ide/test_writer_resolution.pynew file mode 100644index 0000000000..6ff8d2f416--- /dev/null+++ b/tests/unit/agentic_ide/test_writer_resolution.py@@ -0,0 +1,149 @@+"""One resolution order, shared by the prompt composer and the work splitter.++They used to carry a copy of this decision each. That is a drift the user pays+for: moving briefs onto a subscription and still being billed per token for the+split is exactly the surprise this feature exists to remove.+"""+from __future__ import annotations++from types import SimpleNamespace++import pytest++from jarvis.agentic_ide import writer+++def _cfg(choice: str) -> SimpleNamespace:+ return SimpleNamespace(agentic_ide=SimpleNamespace(prompt_writer=choice))+++def test_auto_prefers_a_connected_subscription(monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: "sub-brain")+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_writer()++ assert brain == "sub-brain"+ assert source.startswith("subscription")+++def test_auto_falls_through_to_the_api_tier(monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_writer()++ assert brain == "api-brain"+ assert source == "api"+++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 their+ back — the mirror image of the billing surprise this feature removes."""+ called: list[int] = []+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("api"))+ monkeypatch.setattr(+ writer, "_subscription", lambda cfg, timeout: called.append(1) or "sub-brain"+ )+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_writer()++ assert brain == "api-brain"+ assert source == "api"+ assert not called+++def test_subscription_pin_does_not_silently_bill_the_api(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Pinning 'subscription' and getting an API bill is the exact surprise to+ avoid, so an unhonourable pin degrades to the deterministic prompt."""+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("subscription"))+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: None)+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_writer()++ assert brain is None+ assert source == ""+++def test_a_named_provider_pin_is_honoured_by_the_subscription_path(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("claude-cli"))+ monkeypatch.setattr(+ writer, "_subscription", lambda cfg, timeout: SimpleNamespace(name="claude-cli")+ )+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_writer()++ assert brain is not None+ assert source == "subscription:claude-cli"+++def test_the_timeout_reaches_the_subscription_resolver(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A CLI brain's own voice-tier cap must not kill a call the composer is+ still willing to wait for."""+ seen: list[float | None] = []+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ monkeypatch.setattr(+ writer, "_subscription", lambda cfg, timeout: seen.append(timeout) or "sub"+ )+ monkeypatch.setattr(writer, "_quality", lambda cfg: None)++ writer.resolve_writer(cli_timeout_s=90.0)++ assert seen == [90.0]+++def test_resolution_never_raises(monkeypatch: pytest.MonkeyPatch) -> None:+ """Any failure means the caller uses its deterministic layer, not a crash."""++ def _boom() -> object:+ raise RuntimeError("config exploded")++ monkeypatch.setattr(writer, "_load_config", _boom)++ assert writer.resolve_writer() == (None, "")+++def test_a_failing_subscription_resolver_still_reaches_the_api_tier(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A broken CLI probe must not cost the user their working API path."""++ def _boom(cfg: object, timeout: object) -> object:+ raise RuntimeError("cli probe exploded")++ monkeypatch.setattr(writer, "_load_config", lambda: _cfg("auto"))+ 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"+++def test_both_call_sites_use_this_module() -> None:+ """The drift guard: a second copy of this decision is the bug itself."""+ import inspect++ from jarvis.agentic_ide import prompt_composer, work_split++ for module, function in (+ (prompt_composer, "_resolve_writer"),+ (work_split, "_resolve_splitter"),+ ):+ source = inspect.getsource(getattr(module, function))+ assert "resolve_writer" in source, f"{module.__name__} bypasses the shared order"+ assert (+ "resolve_quality_brain" not in source+ ), f"{module.__name__} still resolves its own writer"