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(agentic-ide): let an addressed pane outrank the desktop gate
Ruben Lütke0b68e1fb0465
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.pyindex eeae56cace..5ff5fceb27 100644--- a/jarvis/agentic_ide/intent.py+++ b/jarvis/agentic_ide/intent.py@@ -248,17 +248,23 @@ _EVERYONE_TEMPLATES: tuple[re.Pattern[str], ...] = tuple(_WORD_RE = re.compile(r"[^\W\d_]+", re.UNICODE)-def _mentions(text: str, candidates: list[str]) -> list[tuple[int, int, str]]:+def _mentions(+ text: str, candidates: list[str], *, fuzzy: bool = True+) -> list[tuple[int, int, str]]:"""Every call-sign the utterance names, as ``(start, end, name)`` in order.Resolution is delegated to ``names.resolve`` word by word, so the phonetictolerance is exactly the one the singular path already ships — a secondmatching rule here would be free to drift away from it.++ ``fuzzy=False`` keeps only names the utterance states exactly (or in a+ spelling that folds to the same sound). See the last-resort branch of+ ``detect_all`` for why that distinction has to exist."""seen: set[str] = set()out: list[tuple[int, int, str]] = []for match in _WORD_RE.finditer(text):- hit = resolve(match.group(0), candidates)+ hit = resolve(match.group(0), candidates, fuzzy=fuzzy)if hit is None or hit in seen:continueseen.add(hit)@@ -361,11 +367,26 @@ def detect_all(kind = KIND_PROMPTanchors = prompt_anchorselif mentions and _looks_like_instruction(text):- # Last resort: the utterance names terminals (possibly garbled) and reads- # as an instruction. Requiring a verb keeps a passing mention ("Kai is a+ # Last resort: the utterance names terminals and reads as an+ # instruction. Requiring a verb keeps a passing mention ("Alex is a# nice name") from being addressed.+ #+ # This is the ONLY branch where the call-sign is the whole case: no+ # "tell X to …", no "X should …" — just a name and a verb. That makes+ # it the branch a merely SIMILAR word can win, and the names are short+ # enough for ordinary speech to score close: measured against the+ # shipping pool "unten" reaches "Hunter" and "dann" reaches "Dana"; the+ # live 2026-07-26 session had "keine" reaching "Kai" and briefing a # i18n-allow: quoted transcript tokens+ # second agent nobody had named. So here — and only here — the name has+ # to be exact (or fold to the same sound, which is what carries a+ # garbled transcript). An addressing shape, being independent evidence,+ # still admits a fuzzy call-sign in the branches above.+ certain = _mentions(text, candidates, fuzzy=False)+ if not certain:+ return []+ mentions = certainkind = KIND_PROMPT- anchors = {name for _, _, name in mentions}+ anchors = {name for _, _, name in certain}else:return []@@ -508,19 +529,38 @@ _NUMBER_WORDS: dict[str, int] = {_AGENT_RE = re.compile(r"\b(claude(?:\s+code)?|codex)\b", re.IGNORECASE)+@dataclass(frozen=True, slots=True)+class SpawnGroup:+ """One "N of agent X" part of a spawn request."""++ count: int+ agent: str | None+ """``"claude"`` / ``"codex"``, or ``None`` to inherit the last pane's."""++@dataclass(frozen=True, slots=True)class SpawnTerminalsRequest:"""A spoken request to open more panes in the coding workspace."""count: int- """How many panes to open, already clamped to a sane range."""+ """TOTAL panes to open across all groups, clamped to the workspace maximum."""agent: str | None- """``"claude"`` / ``"codex"``, or ``None`` to inherit the last pane's."""+ """The first group's agent. Kept flat for the single-agent callers that+ predate mixed fleets; a mixed request is only fully described by+ ``groups``."""utterance: str"""The original utterance, unmodified."""+ groups: tuple[SpawnGroup, ...] = ()+ """The requested fleet, in the order the user said it.++ "5 Codex and 3 Claude Code terminals" is TWO groups. Reading only the first+ number and the first agent — which is what this detector used to do —+ opened five Codex panes and dropped the three Claude ones without telling+ anyone (maintainer report 2026-07-26)."""+def _spoken_count(text: str) -> int:"""The requested number of panes: digits, a number word, or 1.@@ -572,6 +612,72 @@ def detect_spawn()+# --------------------------------------------------------------------------- #+# "…and split the work between you" #+# --------------------------------------------------------------------------- #+# Addressing several panes does not by itself mean dividing the task. "Both of+# you run the tests" is ONE order for two agents; planning a split there would+# spend a provider call to invent two different jobs the user never asked for.+# So a split is only ever an EXPLICIT request.+#+# The trap this detector is shaped around: "aufteilen" / "split" is also+# ordinary coding work ("split the module into two files"). A verb alone is+# therefore not enough — the sentence must also say WHO the work is divided+# between, or into WHAT KIND of parts. Both of those distinguish dividing a+# task across agents from dividing a file into modules.++_DIVIDE_VERB_RE = re.compile(+ r"\b(?:teil\w*|aufteil\w*|verteil\w*|split|splits|divide|divides|"+ r"distribute|reparte|repartan|repartir|dividan|divid[ií]d)\b",+ re.IGNORECASE,+)++#: Who the work is divided between — the agents themselves.+_DIVIDE_RECIPIENT_RE = re.compile(+ r"\b(?:unter\s+euch|untereinander|euch|between\s+you|among\s+"+ r"you(?:rselves)?|entre\s+(?:vosotros|ustedes))\b",+ re.IGNORECASE,+)++#: What kind of parts the work is divided INTO. Deliberately about subject+#: areas, never about code units ("modules", "files", "functions") — dividing+#: those is the work itself, not a plan for the fleet.+_DIVIDE_AREA_RE = re.compile(+ r"\b(?:aufgabenbereich\w*|bereich\w*|themen\w*|themengebiet\w*|"+ r"schwerpunkt\w*|areas?|topics?|domains?|workstreams?|"+ r"[aá]reas?|temas?)\b",+ re.IGNORECASE,+)++#: "each of you takes a different part" — the same request without a verb.+_DIVIDE_EACH_RE = re.compile(+ r"\b(?:jede[rn]?\s+von\s+euch|jede[rn]?\s+einzelne|each\s+of\s+you|"+ r"each\s+one|cada\s+uno)\b[^.!?]{0,40}?"+ r"\b(?:ander\w*|different|separate|own|distinto\w*|diferente\w*|propio)\b",+ re.IGNORECASE,+)+++def wants_split(user_text: str) -> bool:+ """True when the user asked for the work to be DIVIDED across the agents.++ Not a question about how many panes are addressed — that is ``detect_all``.+ This answers the separate question of whether they should all do the same+ thing or different things, which is the difference between one composed+ prompt reused N times and a planned division of labour (``work_split``).+ """+ text = (user_text or "").strip()+ if len(text) < 6:+ return False+ if _DIVIDE_EACH_RE.search(text):+ return True+ if not _DIVIDE_VERB_RE.search(text):+ return False+ return bool(+ _DIVIDE_RECIPIENT_RE.search(text) or _DIVIDE_AREA_RE.search(text)+ )++def owns_turn(user_text: str, *, names: list[str] | None = None) -> bool:"""True when the open workspace should handle this turn instead of a spawn.@@ -611,4 +717,5 @@ __all__ = ["detect_all","detect_spawn","owns_turn",+ "wants_split",]diff --git a/jarvis/agentic_ide/names.py b/jarvis/agentic_ide/names.pyindex cabd8696a3..91139ca6b9 100644--- a/jarvis/agentic_ide/names.py+++ b/jarvis/agentic_ide/names.py@@ -128,12 +128,28 @@ def phonetic_key(name: str) -> str:return "".join(squeezed)-def resolve(spoken: str, candidates: list[str]) -> str | None:+def resolve(+ spoken: str, candidates: list[str], *, fuzzy: bool = True+) -> str | None:"""Best-matching call-sign for ``spoken``, or ``None`` below the floor.``spoken`` may be a whole utterance ("what is mika up to?") — every word istried, longest first, so a name embedded in a sentence is found without thecaller having to pre-extract it.++ Two strengths of match, and callers pick by what a wrong answer costs them:++ * **exact** — the word IS the name, or folds to the same sound ("Micah" →+ "Mika"). Certain enough to act on with no other evidence.+ * **fuzzy** (``fuzzy=True``, the default) — the word merely SCORES close+ enough. That is what rescues a transcript the phonetic folding does not+ cover, and it is also how ordinary speech collides with the pool: measured+ against the shipping names, "unten" reaches "Hunter" and "dann" reaches+ "Dana"; the live 2026-07-26 session had "keine" reaching "Kai" # i18n-allow: quoted transcript tokens+ (everyday words of the spoken language, quoted as measurement data).+ Below the floor those are indistinguishable from a garbled call-sign, so+ a caller that would ACT on the answer alone passes ``fuzzy=False`` and+ accepts an exact match only."""if not spoken or not candidates:return None@@ -154,6 +170,8 @@ def resolve(spoken: str, candidates: list[str]) -> str | None:for key, original in keys.items():if folded and folded == phonetic_key(key):return original+ if not fuzzy:+ continue# Score the raw spelling AND the folded one; the better of the two# decides, so an odd transcript has two chances to be recognised.score = max(diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 1ebc249715..98b607cba0 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -5720,6 +5720,27 @@ class BrainManager:)return f"Öffne {label}." if is_de else f"Opening {label}." # i18n-allow+ def _agentic_ide_owns_turn(self, user_text: str) -> bool:+ """True when this turn belongs to the open coding workspace.++ Asked by the deterministic gates that would otherwise consume the turn+ first — today the desktop/Computer-Use gate. The answer comes from+ ``intent.owns_turn``, the one precedence rule the force-spawn guard and+ the spawn gate already share, so a fourth opinion cannot appear here.++ Cost is a regex sweep over the in-memory session, no IO and no LLM+ (AP-9 / AP-11), so it is safe to ask on every turn of the voice hot+ path. Any fault answers "no": the workspace is an optional surface and+ must never be able to divert a turn away from the path that would+ otherwise have served it.+ """+ try:+ from jarvis.agentic_ide.intent import owns_turn++ return owns_turn(user_text)+ except Exception: # noqa: BLE001 - optional surface, never fatal+ return False+async def _run_agentic_ide_fast_path(self,user_text: str,@@ -5795,6 +5816,35 @@ class BrainManager:if found.kind == ide_intent.KIND_REPORT:return None+ names = [item.terminal for item in addressed]++ # Two agents told to "split the work between you" must get DIFFERENT+ # briefs — the same sentence twice is two agents racing on one file.+ # Only an explicit request plans a split: it costs a provider call, and+ # "both of you run the tests" is one order for two agents.+ assignments: dict[str, str] | None = None+ if len(names) > 1 and ide_intent.wants_split(user_text):+ try:+ from jarvis.agentic_ide import work_split as ide_split++ plan = await ide_split.split(+ found.instruction or user_text,+ session=session,+ count=len(names),+ )+ assignments = {+ name: item.task+ for name, item in zip(names, plan.assignments, strict=False)+ }+ log.info(+ "Agentic IDE fan-out: work split %s across %d panes (%s)",+ plan.split_by, len(assignments),+ ", ".join(a.area for a in plan.assignments),+ )+ except Exception: # noqa: BLE001 - an unplanned fleet still works+ log.warning("Agentic IDE work split failed", exc_info=True)+ assignments = None+# No brain is pinned for the composer on purpose. An earlier version# handed it this turn's FAST router model to save 4-5 s, but that# optimised the wrong axis: the prompt is what the coding agent then@@ -5805,9 +5855,10 @@ class BrainManager:try:result = await ide_fanout.deliver(session=session,- terminals=[item.terminal for item in addressed],+ terminals=names,utterance=user_text,instruction=found.instruction,+ assignments=assignments,)except Exception: # noqa: BLE001 - never crash the turn over a panelog.warning("Agentic IDE fast-path failed", exc_info=True)diff --git a/tests/unit/brain/test_cu_vs_agentic_ide_routing.py b/tests/unit/brain/test_cu_vs_agentic_ide_routing.pynew file mode 100644index 0000000000..93211d9ba2--- /dev/null+++ b/tests/unit/brain/test_cu_vs_agentic_ide_routing.py@@ -0,0 +1,278 @@+"""Computer-Use-vs-Agentic-IDE routing (desktop verbs inside a pane order).++Live bug (voice session 2026-07-26 09:44, focused coding mode ON, twelve panes+open): the user asked, in German, for the pane called Bruno to do a deep dive+into why text cannot be pasted in the Agentic IDE. The verbatim transcript is+``LIVE_FAILURE`` below. Jarvis did not brief Bruno. It drove Computer-Use+instead, clicked into the workspace's own chat box and typed a prompt there —+the assistant operating its own UI by hand while a coding agent named in the+sentence sat idle.++Root cause (measured, not guessed): two deterministic gates claim this turn and+the older one runs first. ``BrainManager.think`` consults+``_run_local_action_fast_path`` before ``_run_agentic_ide_fast_path``, and the+desktop gate matches on the GUI verb "kopieren" — a word that appears here in+the *description of the problem*, never as an order to copy anything. A gate+that reads intent from single verbs cannot tell "copy this" from "copying is+broken", so the tie has to be broken by the stronger signal: the user named a+pane.++This is the sibling of ``test_cu_vs_spawn_routing.py``. There a depth marker+("Deep Dive") wrongly beat an explicit screen request; here a screen verb+wrongly beats an explicitly addressed terminal. Same shape, opposite direction:+whichever gate holds the more specific evidence wins.++The second half is why the reordering alone would not be safe. Name resolution+is fuzzy on purpose (a call-sign arrives through speech recognition), and the+weakest evidence path in ``intent.detect_all`` — "the utterance names a pane and+contains a verb" — accepts a merely *similar* word. Measured against the+shipping name pool, "unten" resolves to "Hunter" and "dann" to "Dana"; against+the live session's pool "keine" resolved to "Kai" # i18n-allow: quoted transcript tokens+(all four are everyday words of the spoken language, quoted as measurement+data), which is how the failing turn addressed a second pane nobody had+named. Letting the workspace outrank the+desktop gate on that evidence would hand ordinary desktop commands to a coding+agent. So a name that is only *approximately* right can no longer claim a turn+on its own.++Deterministic throughout: real gate, real detector, faked prompt composer.+"""+from __future__ import annotations++from pathlib import Path++import pytest++from jarvis.agentic_ide import intent, prompt_composer+from jarvis.agentic_ide import session as session_mod+from jarvis.agentic_ide.prompt_composer import ComposedPrompt+from jarvis.agentic_ide.session import Registry+from jarvis.brain.local_action_gate import LocalActionMode, match_local_action+from jarvis.brain.manager import BrainManager+from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from tests.fakes.fake_pty_manager import FakePtyManager++# The verbatim transcript of the live failure, as the session log recorded it.+LIVE_FAILURE = (+ "Deine Aufgabe ist es Bruno einen Deep Dive machen zu lassen und zu " # i18n-allow: German speech input under test+ "schauen, wieso man ähm bei Personal Jabber in der Igentic IDE Mode ähm " # i18n-allow: German speech input under test+ "keine Texte rein kopieren kann. Also z.B. mit Steuerung STRG ähm + V " # i18n-allow: German speech input under test+ "kann man keine Texte einkopieren auf Windows und es soll natürlich auf " # i18n-allow: German speech input under test+ "jedem Betriebssystem funktionieren. Schau dir das an und hilf mir dabei " # i18n-allow: German speech input under test+ "das zu fixen." # i18n-allow: German speech input under test+)++[email protected](autouse=True)+def _isolated_recents(+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Never rewrite the developer's real recent-workspace list from a test."""+ from jarvis.agentic_ide import recents++ store = tmp_path_factory.mktemp("recents") / "recents.json"+ monkeypatch.setattr(recents, "_store_path", lambda: store)++[email protected](autouse=True)+def _fake_composer(monkeypatch: pytest.MonkeyPatch) -> None:+ """A deterministic stand-in for the quality-tier prompt writer."""++ async def fake_compose(utterance: str, **kwargs: object) -> ComposedPrompt:+ name = kwargs["terminal_name"]+ instruction = kwargs.get("instruction") or utterance+ return ComposedPrompt(+ text=f"## Task for {name}\n{instruction}",+ files=["jarvis/core/bus.py"],+ composed_by="llm",+ )++ monkeypatch.setattr(prompt_composer, "compose", fake_compose)+++def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))+ reg = Registry(pty_manager=FakePtyManager())+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)+ return reg+++def manager() -> BrainManager:+ cfg = JarvisConfig()+ cfg.brain.primary = "fake"+ mgr = BrainManager(config=cfg, bus=EventBus(), tools={})+ # Pinned so wording assertions do not depend on the host's locale+ # (AP-23: never test against the maintainer's own configuration).+ mgr._reply_language = "en"+ return mgr+++async def _noop(_text: str) -> None:+ return None+++async def _noop_exit(_code: int) -> None:+ return None+++async def _open(registry: Registry, folder: Path, count: int) -> None:+ """Open ``count`` panes AND bring their agents live."""+ await registry.start(str(folder), [{"agent": "claude"} for _ in range(count)])+ assert registry.session is not None+ for term in list(registry.session.terminals):+ await registry.attach(term.name, 100, 30, _noop, _noop_exit)+++def _names(registry: Registry) -> list[str]:+ assert registry.session is not None+ return [t.name for t in registry.session.terminals]+++def _prompted(registry: Registry) -> list[str]:+ """Every pane that actually received a prompt."""+ assert registry.session is not None+ return [t.name for t in registry.session.terminals if t.prompts_sent > 0]+++# --------------------------------------------------------------------------- #+# The collision itself #+# --------------------------------------------------------------------------- #+++def test_the_desktop_gate_really_does_claim_this_turn() -> None:+ """Pin the precondition, so the guard below is never tested against a myth.++ If this ever stops holding, the ordering guard has become dead weight and+ the tests that follow would pass for the wrong reason.+ """+ plan = match_local_action(LIVE_FAILURE, "de")+ assert plan is not None+ assert plan.mode is LocalActionMode.COMPUTER_USE+++def test_an_addressed_pane_outranks_the_desktop_gate() -> None:+ """The workspace owns the turn although it is full of GUI vocabulary."""+ assert intent.owns_turn(LIVE_FAILURE, names=["Bruno", "Iris", "Vega"]) is True+++async def test_live_failure_briefs_the_pane_instead_of_driving_the_screen(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """End to end: the exact utterance must reach the addressed agent."""+ await _open(registry, tmp_path, 3)+ addressed = _names(registry)[1]++ reply = await manager._run_agentic_ide_fast_path(+ LIVE_FAILURE.replace("Bruno", addressed)+ )++ assert reply is not None+ assert _prompted(registry) == [addressed]+++async def test_the_desktop_gate_stands_down_while_a_pane_is_addressed(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """The guard ``think`` consults before it runs the desktop fast path.++ Asked against a REAL open workspace, because the whole failure was that the+ gate never learned a workspace was there.+ """+ await _open(registry, tmp_path, 3)+ addressed = _names(registry)[1]++ assert manager._agentic_ide_owns_turn(+ LIVE_FAILURE.replace("Bruno", addressed)+ ) is True+++ "utterance",+ [+ "kopier den Text aus dem Fenster", # i18n-allow: German speech input under test+ "mach mal einen Screenshot vom Bildschirm", # i18n-allow: German speech input under test+ ],+)+async def test_the_desktop_gate_keeps_screen_work_with_a_workspace_open(+ manager: BrainManager, registry: Registry, tmp_path: Path, utterance: str+) -> None:+ """Having panes open must not turn the assistant into a pane-only agent.++ An open workspace is the normal state while coding; if it withdrew the+ desktop gate wholesale, "take a screenshot" would stop working for as long+ as the IDE is up.+ """+ await _open(registry, tmp_path, 3)++ assert manager._agentic_ide_owns_turn(utterance) is False+++async def test_no_workspace_open_changes_nothing(manager: BrainManager) -> None:+ """With no session at all the guard is inert — the common case."""+ assert manager._agentic_ide_owns_turn(LIVE_FAILURE) is False+++# --------------------------------------------------------------------------- #+# ... without swallowing genuine desktop commands #+# --------------------------------------------------------------------------- #+++ "utterance",+ [+ "kopier den Text aus dem Fenster", # i18n-allow: German speech input under test+ "mach mal einen Screenshot vom Bildschirm", # i18n-allow: German speech input under test+ "copy the text from that window",+ ],+)+def test_a_plain_desktop_command_keeps_its_turn(utterance: str) -> None:+ """No pane named, no claim — Computer-Use still owns these."""+ assert intent.owns_turn(utterance, names=["Bruno", "Hunter", "Dana"]) is False+++ ("utterance", "pane"),+ [+ # "unten" (below) sounds close enough to "Hunter" to resolve, and+ # "dann" (then) to "Dana" — both measured against the shipping pool.+ ("mach das Fenster unten zu und kopier den Text", "Hunter"), # i18n-allow: German speech input under test+ ("klick da oben drauf und dann kopier das", "Dana"), # i18n-allow: German speech input under test+ ],+)+def test_a_merely_similar_word_never_addresses_a_pane(+ utterance: str, pane: str+) -> None:+ """The weak evidence path must not hand desktop work to a coding agent.++ Without this, making the workspace outrank the desktop gate would be a net+ loss: ordinary screen commands would be typed into a pane whose call-sign+ merely rhymes with a word in the sentence.+ """+ assert intent.detect(utterance, names=[pane, "Alex", "Blake"]) is None+ assert intent.owns_turn(utterance, names=[pane, "Alex", "Blake"]) is False+++def test_an_exactly_named_pane_still_claims_the_weak_path() -> None:+ """The recall side of the same rule: a real name needs no addressing shape.++ "Bruno" in the live failure carried no "tell X to ..." construction — it was+ found purely because the utterance names a pane and reads as an instruction.+ That path has to survive the hardening above.+ """+ found = intent.detect(LIVE_FAILURE, names=["Bruno", "Iris"])+ assert found is not None+ assert found.terminal == "Bruno"+++def test_only_the_named_pane_is_briefed() -> None:+ """The live turn addressed exactly one pane, not two.++ In the live session an ordinary negation word of the spoken language+ resolved to the call-sign "Kai", so the fan-out would have briefed a second+ agent the user never named — and reported both as working.+ """+ addressed = intent.detect_all(LIVE_FAILURE, names=["Bruno", "Kai", "Iris"])+ assert [item.terminal for item in addressed] == ["Bruno"]