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): fan one spoken order out to several agents, honestly
Ruben Lütke686b4a042b74
diff --git a/jarvis/agentic_ide/fanout.py b/jarvis/agentic_ide/fanout.pynew file mode 100644index 0000000000..c4432f912b--- /dev/null+++ b/jarvis/agentic_ide/fanout.py@@ -0,0 +1,289 @@+"""Deliver one spoken order to SEVERAL terminals of the open workspace.++The single-pane path (``BrainManager._run_agentic_ide_fast_path``) composes a+prompt and types it into one terminal. Doing that in a loop looks like the+obvious extension and is wrong twice over, which is why this is its own module:++**Latency.** Composing a prompt is a deliberate quality-tier call — 10-21 s+measured, chosen over a 2 s rewrite because the coding agent then works from+that prompt for minutes (maintainer decision 2026-07-25). A delegated voice+turn is abandoned after 20 s. Two panes composed one after another therefore+cannot fit in ANY turn, and eight cannot fit in a coffee break. Composition+runs concurrently here, bounded so a fleet of twenty does not fire twenty+provider calls into a rate limit at once.++**Honesty.** A loop that raises on the first dead pane leaves the earlier panes+briefed and the later ones untouched, with one exception to explain all of it.+A loop that swallows failures is worse: it produced the live 2026-07-26 lie,+where one of two agents was briefed and the user was told both were working.+So nothing here raises for a single pane's failure — every terminal comes back+with its own verdict, and the caller is expected to SAY the undelivered ones+out loud. ``FanOutResult`` deliberately has no boolean "ok": the interesting+state is the partial one, and a single flag hides it.++Cost: one composer call per pane and one PTY write per pane, all off the wake+path (AP-9). No LLM call is made here directly — the composer owns that, and+degrades to its deterministic prompt when no provider is reachable, so a+downloader with no API key still gets every agent briefed (§3).+"""+from __future__ import annotations++import asyncio+import logging+from collections.abc import Awaitable, Callable, Mapping, Sequence+from dataclasses import dataclass+from typing import Any++log = logging.getLogger(__name__)++#: How many prompts may be composed at the same time. The bound exists for the+#: provider, not for us: the composer resolves a quality-tier model, and twenty+#: simultaneous calls is how a fleet-wide fan-out earns a 429 that degrades+#: every pane to the deterministic prompt at once. Five keeps a realistic fleet+#: (3-8 panes) in a single wave while staying polite.+DEFAULT_CONCURRENCY = 5+++@dataclass(frozen=True, slots=True)+class Delivery:+ """What happened to ONE addressed terminal."""++ terminal: str+ delivered: bool+ """The prompt reached this pane's input box."""++ submitted: bool | None = None+ """…and the agent accepted it and started. ``None`` when the sender does not+ report it.++ Deliberately separate from ``delivered``: a prompt ending in an ``@file``+ reference gets typed and then swallowed by the agent's completion popup, so+ it sits in the input box looking exactly like a running task (the 2026-07-25+ three-panes-one-ran failure). "Typed" and "started" are different claims and+ the readback must be able to tell them apart."""++ files: tuple[str, ...] = ()+ composed_by: str = ""+ reason_code: str = ""+ """Machine-readable failure kind: ``unknown_pane``, ``not_running``,+ ``compose_failed``, ``empty_prompt``, ``send_failed``, ``crashed``.++ The spoken layer localizes from THIS, never from ``reason`` — an English+ sentence pasted into a German answer is exactly the mixed-language output+ the per-turn resolver exists to prevent (CLAUDE.md, runtime output+ language)."""++ reason: str = ""+ """Why it was not delivered, in English, for logs and the REST/CLI surface.+ Empty on success."""++ status: str = ""+ """The pane's status when it could not be reached — the one detail worth+ speaking ("its agent is exited")."""+++@dataclass(frozen=True, slots=True)+class FanOutResult:+ """Per-terminal verdicts for one fan-out, in the order they were addressed."""++ deliveries: tuple[Delivery, ...] = ()++ @property+ def delivered(self) -> tuple[Delivery, ...]:+ return tuple(d for d in self.deliveries if d.delivered)++ @property+ def undelivered(self) -> tuple[Delivery, ...]:+ return tuple(d for d in self.deliveries if not d.delivered)++ @property+ def all_delivered(self) -> bool:+ """True only when there was work AND every pane took it."""+ return bool(self.deliveries) and not self.undelivered++ @property+ def partial(self) -> bool:+ """The state a readback must never round up: some worked, some did not."""+ return bool(self.delivered) and bool(self.undelivered)++ @property+ def typed_but_not_started(self) -> tuple[Delivery, ...]:+ """Panes holding the prompt in their input box without running it."""+ return tuple(d for d in self.deliveries if d.delivered and d.submitted is False)+++def _unique(terminals: Sequence[str]) -> list[str]:+ """Call-signs in the order given, without repeats.++ A spoken transcript names the same pane twice more often than one would+ think ("Iris and Bruno ... and Iris should also ..."), and briefing it+ twice submits two tasks to an agent that can only work on one.+ """+ seen: set[str] = set()+ out: list[str] = []+ for name in terminals:+ key = (name or "").casefold()+ if not key or key in seen:+ continue+ seen.add(key)+ out.append(name)+ return out+++async def _default_compose(utterance: str, **kwargs: Any) -> Any:+ from .prompt_composer import compose as compose_prompt++ return await compose_prompt(utterance, **kwargs)+++async def _default_send(name: str, text: str) -> Any:+ from .session import get_registry++ return await get_registry().send_prompt(name, text)+++async def deliver(+ *,+ session: Any,+ terminals: Sequence[str],+ utterance: str,+ instruction: str | None = None,+ assignments: Mapping[str, str] | None = None,+ compose: Callable[..., Awaitable[Any]] | None = None,+ send: Callable[[str, str], Awaitable[Any]] | None = None,+ limit: int = DEFAULT_CONCURRENCY,+) -> FanOutResult:+ """Compose and deliver a prompt for each of ``terminals``.++ ``assignments`` maps a call-sign to ITS OWN instruction and is how a split+ task reaches the fleet — each pane is then briefed on its own slice instead+ of all of them racing on the same one. Without it every pane gets+ ``instruction`` (or the raw utterance), which is the right behaviour for+ "Iris and Bruno, both of you analyse the codebase".++ ``compose`` and ``send`` are injectable so this can be tested without a live+ PTY or a provider; production leaves them at their defaults.++ Never raises for a single pane. A pane that is missing, not running, whose+ prompt could not be written, or whose PTY write failed comes back as an+ undelivered ``Delivery`` carrying the reason.+ """+ wanted = _unique(terminals)+ if not wanted:+ return FanOutResult()++ compose_fn = compose or _default_compose+ send_fn = send or _default_send+ gate = asyncio.Semaphore(max(1, int(limit)))++ async def one(name: str) -> Delivery:+ term = session.find(name) if session is not None else None+ if term is None:+ return Delivery(+ terminal=name,+ delivered=False,+ reason_code="unknown_pane",+ reason="there is no terminal by that name in this workspace",+ )+ # Status and PTY are checked BEFORE composing: a prompt for a dead pane+ # costs a full quality-tier call and can never be typed anywhere.+ status = str(getattr(term, "status", "") or "unknown")+ if status != "live" or not getattr(term, "pty_id", None):+ return Delivery(+ terminal=term.name,+ delivered=False,+ reason_code="not_running",+ reason=f"its agent is {status}, not running",+ status=status,+ )++ own_instruction = (assignments or {}).get(term.name) or instruction+ async with gate:+ try:+ from .session import AGENT_DISPLAY++ composed = await compose_fn(+ utterance,+ session=session,+ terminal_name=term.name,+ agent_display=AGENT_DISPLAY.get(term.agent, term.agent),+ instruction=own_instruction,+ )+ except Exception as exc: # noqa: BLE001 - one pane must not sink the fleet+ log.warning(+ "Agentic IDE fan-out: composing for %s failed", term.name,+ exc_info=True,+ )+ return Delivery(+ terminal=term.name,+ delivered=False,+ reason_code="compose_failed",+ reason=f"its prompt could not be written ({exc})",+ )++ text = getattr(composed, "text", "") or ""+ if not text.strip():+ # An empty prompt would submit a bare Enter into the agent, which+ # reads as "the user pressed return" and can re-run its last task.+ return Delivery(+ terminal=term.name,+ delivered=False,+ reason_code="empty_prompt",+ reason="its prompt came back empty",+ )++ try:+ sent = await send_fn(term.name, text)+ except Exception as exc: # noqa: BLE001 - report, never propagate+ log.info("Agentic IDE fan-out: could not send to %s: %s", term.name, exc)+ return Delivery(+ terminal=term.name,+ delivered=False,+ reason_code="send_failed",+ reason=f"it did not accept the prompt ({exc})",+ )++ # The sender reports whether the agent actually STARTED. A sender that+ # says nothing leaves it None (unknown) rather than claiming success —+ # the readback then stays silent about it instead of overstating.+ submitted = getattr(sent, "submitted", None)+ return Delivery(+ terminal=term.name,+ delivered=True,+ submitted=None if submitted is None else bool(submitted),+ files=tuple(getattr(composed, "files", ()) or ()),+ composed_by=str(getattr(composed, "composed_by", "") or ""),+ )++ # return_exceptions is deliberate belt-and-braces: `one` already contains+ # every failure it can foresee, and an unforeseen one must still not cancel+ # the siblings mid-write.+ results = await asyncio.gather(+ *(one(name) for name in wanted), return_exceptions=True+ )+ deliveries: list[Delivery] = []+ for name, result in zip(wanted, results, strict=True):+ if isinstance(result, Delivery):+ deliveries.append(result)+ continue+ log.warning("Agentic IDE fan-out: %s failed unexpectedly: %r", name, result)+ deliveries.append(+ Delivery(+ terminal=name,+ delivered=False,+ reason_code="crashed",+ reason=f"it failed ({result})",+ )+ )++ out = FanOutResult(deliveries=tuple(deliveries))+ log.info(+ "Agentic IDE fan-out: %d of %d delivered (%s)",+ len(out.delivered),+ len(out.deliveries),+ ", ".join(d.terminal for d in out.delivered) or "none",+ )+ return out+++__all__ = ["DEFAULT_CONCURRENCY", "Delivery", "FanOutResult", "deliver"]diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 6e59880764..1ebc249715 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -27,7 +27,14 @@ import asyncioimport loggingimport reimport time-from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Mapping+from collections.abc import (+ AsyncIterator,+ Awaitable,+ Callable,+ Iterable,+ Mapping,+ Sequence,+)from contextvars import ContextVarfrom typing import TYPE_CHECKING, Any, Literalfrom uuid import UUID, uuid4@@ -1110,6 +1117,74 @@ def _terminal_not_running_line(terminal: str, status: str, lang: str) -> str:)+def _join_names(names: Sequence[str], lang: str) -> str:+ """Call-signs as a speakable list ("Iris und Bruno", "Iris, Bruno and Casey")."""+ from jarvis.voice.action_phrases import action_phrase++ items = [n for n in names if n]+ if not items:+ return ""+ if len(items) == 1:+ return items[0]+ return action_phrase(+ "ide_names_pair", lang, head=", ".join(items[:-1]), last=items[-1]+ )+++def _fanout_reply_line(result: Any, lang: str) -> str:+ """Spoken readback for a fan-out, naming who got it and who did not.++ The live 2026-07-26 lie came from a readback that could only describe+ success: one pane was briefed, the sentence named one pane, and the realtime+ provider filled the gap from the user's own question ("Iris and Bruno").+ Every branch here therefore names the panes it is talking about, and the+ partial case is its own sentence rather than an optional clause — an+ optional clause is what gets dropped when a model paraphrases.++ A single addressee keeps the exact wording the one-pane path always had:+ that is the common case, and it should not start sounding like a fleet+ operation because the plumbing underneath grew one.+ """+ from jarvis.voice.action_phrases import action_phrase++ deliveries = result.deliveries+ ok = [d.terminal for d in result.delivered]+ bad = [d.terminal for d in result.undelivered]++ if len(deliveries) == 1:+ only = deliveries[0]+ if only.delivered:+ line = _prompt_sent_line(only.terminal, list(only.files), lang)+ elif only.reason_code == "not_running":+ line = _terminal_not_running_line(only.terminal, only.status, lang)+ else:+ line = action_phrase(+ "ide_prompt_sent_nobody", lang, failed=only.terminal+ )+ elif not ok:+ line = action_phrase(+ "ide_prompt_sent_nobody", lang, failed=_join_names(bad, lang)+ )+ elif bad:+ line = action_phrase(+ "ide_prompt_sent_partial",+ lang,+ names=_join_names(ok, lang),+ failed=_join_names(bad, lang),+ )+ else:+ line = action_phrase(+ "ide_prompt_sent_many", lang, names=_join_names(ok, lang)+ )++ stuck = [d.terminal for d in result.typed_but_not_started]+ if stuck:+ line = f"{line} " + action_phrase(+ "ide_prompt_typed_not_started", lang, names=_join_names(stuck, lang)+ )+ return line++def _recent_agent(recent: Any) -> str:"""The coding agent a remembered workspace mostly ran, defaulting to Claude.@@ -5667,31 +5742,36 @@ class BrainManager:briefed task with ``@file`` references. That is one bounded provider callwith a regex fallback, so the instruction is delivered either way.+ Several panes may be addressed in one breath ("Iris und Bruno beide in+ Deep Dive geben"). They are served CONCURRENTLY and reported+ individually — see ``agentic_ide.fanout``, which exists because doing+ this in a loop cannot fit in a voice turn and cannot report a partial+ delivery honestly.+Returns ``None`` whenever this turn is not an addressed terminal, so thenormal path runs untouched."""try:+ from jarvis.agentic_ide import fanout as ide_fanoutfrom jarvis.agentic_ide import intent as ide_intent- from jarvis.agentic_ide.session import (- AGENT_DISPLAY,- SessionError,- get_registry,- )except Exception: # noqa: BLE001 - optional surfacereturn Nonetry:+ from jarvis.agentic_ide.session import get_registry+registry = get_registry()session = registry.sessionif session is None:return None- found = ide_intent.detect(+ addressed = ide_intent.detect_all(user_text, names=[t.name for t in session.terminals])except Exception: # noqa: BLE001 - detection must never break a turnreturn None- if found is None:+ if not addressed:return None+ found = addressed[0]# Naming the spawn vehicle outranks the workspace: "spawn an agent that# helps Kai" is a genuine background-worker request even with a# workspace open. Same test the spawn gate and ``intent.owns_turn`` use,@@ -5715,49 +5795,27 @@ class BrainManager:if found.kind == ide_intent.KIND_REPORT:return None- term = session.find(found.terminal)- if term is None:- return None- if term.status != "live" or not term.pty_id:- log.info(- "Agentic IDE fast-path: %s is %s — nothing sent",- term.name, term.status,- )- return _terminal_not_running_line(term.name, term.status, out_lang)-- from jarvis.agentic_ide.prompt_composer import compose-- composed = await compose(- user_text,- session=session,- terminal_name=term.name,- agent_display=AGENT_DISPLAY.get(term.agent, term.agent),- instruction=found.instruction,- # No brain is pinned here on purpose. An earlier version handed the- # composer 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- # works from for minutes, and the maintainer's decision on- # 2026-07-25 was explicitly for the better prompt over the quicker- # handoff. The composer resolves a quality-tier model itself and- # degrades to its deterministic prompt when none is reachable.- )- if not composed.text:- return 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+ # works from for minutes, and the maintainer's decision on 2026-07-25+ # was explicitly for the better prompt over the quicker handoff. The+ # composer resolves a quality-tier model itself and degrades to its+ # deterministic prompt when none is reachable.try:- await registry.send_prompt(term.name, composed.text)- except SessionError as exc:- log.info("Agentic IDE fast-path could not send to %s: %s", term.name, exc)- return str(exc)+ result = await ide_fanout.deliver(+ session=session,+ terminals=[item.terminal for item in addressed],+ utterance=user_text,+ instruction=found.instruction,+ )except Exception: # noqa: BLE001 - never crash the turn over a panelog.warning("Agentic IDE fast-path failed", exc_info=True)return None- log.info(- "Agentic IDE fast-path -> %s (composed_by=%s, files=%d)",- term.name, composed.composed_by, len(composed.files),- )- return _prompt_sent_line(term.name, composed.files, out_lang)+ if not result.deliveries:+ return None+ return _fanout_reply_line(result, out_lang)async def _run_agentic_ide_spawn_fast_path(self,@@ -8302,7 +8360,28 @@ class BrainManager:)return mission_reply- if self._skill_turn_match is None:+ # An addressed Agentic-IDE terminal outranks the desktop gate — the+ # mirror image of the skill stand-down just above, and for the same+ # reason: whichever gate holds the MORE SPECIFIC evidence wins.+ #+ # Live bug 2026-07-26 09:44 (coding mode on, twelve panes open): "let+ # Bruno do a deep dive and look into why you cannot paste text in the+ # Agentic IDE" reached Computer-Use, which clicked into the workspace's+ # own chat box and typed a prompt there — Jarvis operating its own UI by+ # hand while the agent named in the sentence sat idle. The gate had+ # matched the GUI verb "kopieren", a word that appears in that sentence+ # as the DESCRIPTION of a bug, never as an order to copy anything. A+ # single-verb matcher cannot tell "copy this" from "copying is broken",+ # whereas naming a running pane is unambiguous.+ #+ # ``owns_turn`` is the shared precedence the force-spawn guard and the+ # spawn gate already consult (it stands down by itself when the user+ # names the background-worker vehicle), so this third consumer cannot+ # drift away from them. The turn is not answered here — it simply stays+ # available for the Agentic-IDE fast path a few lines below.+ if self._skill_turn_match is None and not self._agentic_ide_owns_turn(+ user_text+ ):local_action = await self._run_local_action_fast_path(user_text, trace_id=turn_trace_id,)diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 7e4dcf4716..319b3b2188 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -310,6 +310,14 @@ _DELEGATE_ROLE_DIRECTIVE = ("was started, completed, saved, opened, or changed unless the latest ""successful jarvis_action result explicitly supports that claim. A promise ""or an intention is not a result. "+ "When a request names SEVERAL targets — several coding agents, files, "+ "people, or items — report ONLY the ones the result actually names as "+ "done. Never carry a name over from the user's own question into your "+ "answer: if they asked for two and the result names one, say which one it "+ "was and that the other was not reached. Reporting two because two were "+ "asked for is the exact failure this rule exists for (live 2026-07-26: one "+ "of two coding agents was briefed and the user was told both were "+ "working). ""For some turns the Jarvis orchestrator takes over and injects a trusted ""result on its own; a separate instruction tells you when that is the case, ""and only then do you wait instead of calling. The function returns "diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.pyindex 602b5a98c1..b6b3accecc 100644--- a/jarvis/voice/action_phrases.py+++ b/jarvis/voice/action_phrases.py@@ -326,6 +326,39 @@ _PHRASES: dict[str, dict[str, str]] = {"en": "{terminal} is not running right now ({status}). I sent nothing.","es": "{terminal} no está en marcha ahora ({status}). No envié nada.",},+ # Fan-out: ONE order handed to SEVERAL panes. The partial and the+ # nobody-reached cases are separate keys on purpose — the live 2026-07-26+ # failure was a partial delivery spoken as a complete one, and a single+ # template with an optional clause is exactly how that rounds back up.+ "ide_prompt_sent_many": {+ "de": "Ist bei {names}.", # i18n-allow+ "en": "Sent to {names}.",+ "es": "Enviado a {names}.",+ },+ "ide_prompt_sent_partial": {+ "de": "Ist bei {names}. Zu {failed} bin ich nicht durchgekommen.", # i18n-allow+ "en": "Sent to {names}. I could not reach {failed}.",+ "es": "Enviado a {names}. No pude llegar a {failed}.",+ },+ "ide_prompt_sent_nobody": {+ "de": "Ich bin zu {failed} nicht durchgekommen, es läuft nichts.", # i18n-allow+ "en": "I could not reach {failed}, so nothing is running.",+ "es": "No pude llegar a {failed}, así que no hay nada en marcha.",+ },+ # Typed into the input box but never submitted — looks identical to a+ # running agent until you ask it something (the 2026-07-25 popup trap).+ "ide_prompt_typed_not_started": {+ "de": "Bei {names} steht der Text nur im Eingabefeld.", # i18n-allow+ "en": "On {names} the text is only sitting in the input box.",+ "es": "En {names} el texto solo está en el cuadro de entrada.",+ },+ # Joining call-signs for speech. A comma-separated list read aloud sounds+ # like an enumeration that never ends; the last pair needs the conjunction.+ "ide_names_pair": {+ "de": "{head} und {last}", # i18n-allow+ "en": "{head} and {last}",+ "es": "{head} y {last}",+ },# Opening more panes by voice ("spawn five more Claude Code terminals").# The names are always read back: they are how the user addresses the new# panes in the very next sentence, and hearing them is also the fastest waydiff --git a/tests/unit/agentic_ide/test_fanout.py b/tests/unit/agentic_ide/test_fanout.pynew file mode 100644index 0000000000..bf3e2b7f70--- /dev/null+++ b/tests/unit/agentic_ide/test_fanout.py@@ -0,0 +1,301 @@+"""Guards for delivering ONE spoken order to SEVERAL terminals.++Live failure this exists for (voice session 2026-07-26 09:18): "Iris und Bruno+beide in Deep Dive geben" briefed Iris, and the answer claimed both agents were+working. Two properties have to hold at once, and they are easy to get wrong in+opposite directions:++* **Every addressee is actually served.** A fan-out that stops at the first+ failure leaves the user with a partially-briefed fleet and no way to tell.+* **The result says exactly who got what.** A pane that was dead, or whose+ prompt could not be written, must come back named — silence there is what+ turned a one-of-two delivery into a spoken lie.++Concurrency is a correctness property here, not a nicety: composing one prompt+takes the quality tier 10-21 s, and a voice turn is abandoned after 20 s. Eight+panes composed one after another cannot be delivered inside any turn at all, so+the peak-concurrency guard below pins the behaviour the feature depends on.+"""+from __future__ import annotations++import asyncio+from dataclasses import dataclass, field+from types import SimpleNamespace++import pytest++from jarvis.agentic_ide import fanout+from jarvis.agentic_ide.prompt_composer import ComposedPrompt+++@dataclass+class FakeTerminal:+ name: str+ agent: str = "claude"+ status: str = "live"+ pty_id: str | None = "pty-1"+++@dataclass+class FakeSession:+ terminals: list[FakeTerminal]+ folder: str = "/repo"++ def find(self, wanted: str) -> FakeTerminal | None:+ for term in self.terminals:+ if term.name.casefold() == (wanted or "").casefold():+ return term+ return None+++@dataclass+class Recorder:+ """Collects what was composed and what was typed into which pane."""++ sent: dict[str, str] = field(default_factory=dict)+ composed_for: list[str] = field(default_factory=list)+ active: int = 0+ peak: int = 0+ fail_compose_for: tuple[str, ...] = ()+ fail_send_for: tuple[str, ...] = ()+ empty_compose_for: tuple[str, ...] = ()+ delay: float = 0.02++ async def compose(self, utterance: str, **kwargs) -> ComposedPrompt:+ name = kwargs["terminal_name"]+ self.composed_for.append(name)+ self.active += 1+ self.peak = max(self.peak, self.active)+ try:+ await asyncio.sleep(self.delay)+ if name in self.fail_compose_for:+ raise RuntimeError(f"composer exploded for {name}")+ if name in self.empty_compose_for:+ return ComposedPrompt(text="")+ instruction = kwargs.get("instruction") or utterance+ return ComposedPrompt(+ text=f"## Task for {name}\n{instruction}",+ files=["jarvis/core/bus.py"],+ composed_by="llm",+ )+ finally:+ self.active -= 1++ not_submitted_for: tuple[str, ...] = ()++ async def send(self, name: str, text: str) -> SimpleNamespace:+ if name in self.fail_send_for:+ raise RuntimeError(f"pty write failed for {name}")+ self.sent[name] = text+ # Mirrors Registry.send_prompt, which returns the Terminal carrying the+ # submitted flag.+ return SimpleNamespace(+ name=name, submitted=name not in self.not_submitted_for+ )+++def _session(*names: str) -> FakeSession:+ return FakeSession(terminals=[FakeTerminal(name=n) for n in names])+++async def test_every_addressed_terminal_receives_a_prompt() -> None:+ rec = Recorder()+ result = await fanout.deliver(+ session=_session("Iris", "Bruno"),+ terminals=["Iris", "Bruno"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert sorted(rec.sent) == ["Bruno", "Iris"]+ assert result.all_delivered is True+ assert [d.terminal for d in result.delivered] == ["Iris", "Bruno"]+++async def test_prompts_are_composed_concurrently() -> None:+ """Composed one after another, eight panes cannot fit in a voice turn."""+ rec = Recorder()+ await fanout.deliver(+ session=_session("Iris", "Bruno", "Casey"),+ terminals=["Iris", "Bruno", "Casey"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert rec.peak >= 2, "compositions ran sequentially"+++async def test_concurrency_stays_within_the_limit() -> None:+ """A fleet of twenty must not fire twenty provider calls at once."""+ rec = Recorder()+ names = [f"Pane{i}" for i in range(8)]+ await fanout.deliver(+ session=_session(*names),+ terminals=names,+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ limit=3,+ )+ assert rec.peak <= 3+ assert len(rec.sent) == 8+++async def test_a_dead_pane_is_reported_by_name() -> None:+ session = _session("Iris", "Bruno")+ session.terminals[1].status = "exited"+ session.terminals[1].pty_id = None+ rec = Recorder()++ result = await fanout.deliver(+ session=session,+ terminals=["Iris", "Bruno"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert list(rec.sent) == ["Iris"]+ assert [d.terminal for d in result.undelivered] == ["Bruno"]+ assert result.all_delivered is False+ assert "exited" in result.undelivered[0].reason+++async def test_an_unknown_call_sign_is_reported_not_dropped() -> None:+ rec = Recorder()+ result = await fanout.deliver(+ session=_session("Iris"),+ terminals=["Iris", "Ghost"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert [d.terminal for d in result.undelivered] == ["Ghost"]+++async def test_one_failure_does_not_stop_the_others() -> None:+ rec = Recorder(fail_send_for=("Bruno",))+ result = await fanout.deliver(+ session=_session("Iris", "Bruno", "Casey"),+ terminals=["Iris", "Bruno", "Casey"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert sorted(rec.sent) == ["Casey", "Iris"]+ assert [d.terminal for d in result.undelivered] == ["Bruno"]+ assert result.partial is True+++async def test_a_composer_crash_is_contained_to_its_pane() -> None:+ rec = Recorder(fail_compose_for=("Iris",))+ result = await fanout.deliver(+ session=_session("Iris", "Bruno"),+ terminals=["Iris", "Bruno"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert list(rec.sent) == ["Bruno"]+ assert [d.terminal for d in result.undelivered] == ["Iris"]+++async def test_an_empty_composition_is_never_typed() -> None:+ """Typing an empty prompt would submit a bare Enter into the agent."""+ rec = Recorder(empty_compose_for=("Bruno",))+ result = await fanout.deliver(+ session=_session("Iris", "Bruno"),+ terminals=["Iris", "Bruno"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert "Bruno" not in rec.sent+ assert [d.terminal for d in result.undelivered] == ["Bruno"]+++async def test_per_terminal_assignments_beat_the_shared_instruction() -> None:+ """The hook the work splitter delivers through: one brief per pane."""+ rec = Recorder()+ await fanout.deliver(+ session=_session("Iris", "Bruno"),+ terminals=["Iris", "Bruno"],+ utterance="split the analysis between you",+ assignments={"Iris": "audit the wake path", "Bruno": "audit the UI"},+ compose=rec.compose,+ send=rec.send,+ )+ assert "audit the wake path" in rec.sent["Iris"]+ assert "audit the UI" in rec.sent["Bruno"]+++async def test_no_terminals_is_an_empty_result_not_a_crash() -> None:+ result = await fanout.deliver(+ session=_session("Iris"),+ terminals=[],+ utterance="analyse the codebase",+ compose=Recorder().compose,+ send=Recorder().send,+ )+ assert result.deliveries == ()+ assert result.all_delivered is False+++async def test_the_same_pane_named_twice_is_briefed_once() -> None:+ """A transcript that repeats a call-sign must not double-submit."""+ rec = Recorder()+ await fanout.deliver(+ session=_session("Iris"),+ terminals=["Iris", "Iris"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert rec.composed_for == ["Iris"]+++async def test_typed_but_not_started_is_its_own_verdict() -> None:+ """A prompt sitting in the input box is not a running task (2026-07-25)."""+ rec = Recorder(not_submitted_for=("Bruno",))+ result = await fanout.deliver(+ session=_session("Iris", "Bruno"),+ terminals=["Iris", "Bruno"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ # It WAS delivered — the text reached the pane — but it did not start.+ assert result.all_delivered is True+ assert [d.terminal for d in result.typed_but_not_started] == ["Bruno"]+++async def test_a_failure_carries_a_machine_readable_code() -> None:+ """The spoken layer localizes from the code, never from the English reason."""+ session = _session("Iris")+ session.terminals[0].status = "exited"+ session.terminals[0].pty_id = None++ result = await fanout.deliver(+ session=session,+ terminals=["Iris"],+ utterance="analyse the codebase",+ compose=Recorder().compose,+ send=Recorder().send,+ )+ assert result.undelivered[0].reason_code == "not_running"+ assert result.undelivered[0].status == "exited"++[email protected]("status", ["pending", "starting", "exited", "failed"])+async def test_only_a_live_pane_with_a_pty_is_written_to(status: str) -> None:+ session = _session("Iris")+ session.terminals[0].status = status+ rec = Recorder()+ result = await fanout.deliver(+ session=session,+ terminals=["Iris"],+ utterance="analyse the codebase",+ compose=rec.compose,+ send=rec.send,+ )+ assert rec.sent == {}+ assert result.undelivered[0].terminal == "Iris"diff --git a/tests/unit/brain/test_agentic_ide_fanout_fast_path.py b/tests/unit/brain/test_agentic_ide_fanout_fast_path.pynew file mode 100644index 0000000000..48470505ab--- /dev/null+++ b/tests/unit/brain/test_agentic_ide_fanout_fast_path.py@@ -0,0 +1,204 @@+"""Speaking to SEVERAL panes at once, end to end inside the brain.++The 2026-07-26 09:18 failure had two halves, and fixing only one of them would+have been worse than fixing neither:++* **Delivery.** "Iris und Bruno beide in Deep Dive geben" briefed Iris. The+ detector stopped at its first match, so Bruno was never a candidate.+* **Reporting.** The readback named the one pane that got it, the realtime+ provider re-used both names from the question, and the user was told two+ agents were working on a codebase audit when one was. A fan-out that delivers+ to two of three panes and reports success is exactly this bug again, so the+ reply is pinned here as hard as the delivery: every pane that did NOT get the+ prompt must appear in the spoken answer.++The composer is faked throughout. It is a quality-tier provider call by design+(10-21 s), and what these tests are about is the fan-out around it.+"""+from __future__ import annotations++from pathlib import Path++import pytest++from jarvis.agentic_ide import 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.manager import BrainManager+from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from tests.fakes.fake_pty_manager import FakePtyManager++[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 the 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.++ A pane's PTY only spawns when the workspace view mounts it, so a session+ straight out of ``start`` has nothing to type into — attaching is what the+ real UI does and what makes a prompt deliverable.+ """+ 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 _sent_to(registry: Registry, name: str) -> bool:+ """True when this pane actually received a prompt."""+ assert registry.session is not None+ term = registry.session.find(name)+ assert term is not None+ return term.prompts_sent > 0+++async def test_two_addressed_panes_both_receive_the_prompt(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ await _open(registry, tmp_path, 2)+ first, second = _names(registry)++ reply = await manager._run_agentic_ide_fast_path(+ f"Tell {first} and {second} to analyse the whole codebase"+ )++ assert reply is not None+ assert _sent_to(registry, first)+ assert _sent_to(registry, second)+++async def test_the_reply_names_every_pane_that_got_it(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ await _open(registry, tmp_path, 2)+ first, second = _names(registry)++ reply = await manager._run_agentic_ide_fast_path(+ f"Tell {first} and {second} to analyse the whole codebase"+ )++ assert reply is not None+ assert first in reply+ assert second in reply+++async def test_a_pane_that_is_not_running_is_named_as_not_reached(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """The half of the live bug that made a partial delivery sound complete."""+ await _open(registry, tmp_path, 2)+ first, second = _names(registry)+ assert registry.session is not None+ dead = registry.session.find(second)+ assert dead is not None+ dead.status = "exited"+ dead.pty_id = None++ reply = await manager._run_agentic_ide_fast_path(+ f"Tell {first} and {second} to analyse the whole codebase"+ )++ assert reply is not None+ assert _sent_to(registry, first)+ # Both names appear — but the dead one must be reported as NOT reached, so+ # the sentence cannot be read as "both are working".+ assert second in reply+ lowered = reply.lower()+ assert any(word in lowered for word in ("not", "could not", "n't"))+++async def test_a_single_addressed_pane_keeps_the_singular_reply(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """One pane is by far the common case and must not gain fan-out wording."""+ await _open(registry, tmp_path, 2)+ first, second = _names(registry)++ reply = await manager._run_agentic_ide_fast_path(+ f"Tell {first} to run the test suite"+ )++ assert reply is not None+ assert first in reply+ assert second not in reply+ assert not _sent_to(registry, second)+++async def test_nobody_reachable_is_never_reported_as_sent(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ await _open(registry, tmp_path, 2)+ first, second = _names(registry)+ assert registry.session is not None+ for name in (first, second):+ term = registry.session.find(name)+ assert term is not None+ term.status = "exited"+ term.pty_id = None++ reply = await manager._run_agentic_ide_fast_path(+ f"Tell {first} and {second} to analyse the whole codebase"+ )++ assert reply is not None+ lowered = reply.lower()+ assert any(word in lowered for word in ("not", "could not", "n't"))