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): recover when the user says a briefing never arrived
Ruben Lütkea4884343c28d
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.pyindex 92f239145b..a7009f508a 100644--- a/jarvis/agentic_ide/intent.py+++ b/jarvis/agentic_ide/intent.py@@ -1819,6 +1819,72 @@ def references_recent_fleet(user_text: str) -> bool:return bool(_RECENT_FLEET_RE.search(user_text or ""))+# The user telling us a delivery did not happen, or asking for it again. These+# sentences name no pane and carry no instruction — they are only meaningful+# against the turn before them, which is exactly why every detector in this+# module used to return nothing for them.+#+# Live failure 2026-07-29 17:04 (BUG-121): after a briefing was stolen by+# another gate, "Du hast es gar nicht gepromptet" produced no routing signal at+# all, the realtime model answered alone, and it apologised and promised to do+# it "now" without anything happening. The next turn was identical and only+# worked because the model happened to call the action tool by itself. Two+# wasted turns and an apology are not a recovery path.+#+# Deliberately narrow: a complaint must be NEGATED or an explicit retry. "Hast+# du T7 gepromptet?" is a question and must keep reaching the report path.+# Matching *input vocabulary* across the supported locales, not prose.+_UNDELIVERED_COMPLAINT_RE = re.compile(+ r"(?:"+ # "du hast es (gar) nicht gepromptet" / "das war noch nicht gepromptet"+ r"\b(?:hast|hat|habt|war|wars|ist|wurde|wurden)\b[^.!?]{0,40}?" # i18n-allow: input vocab+ r"\bnicht\b[^.!?]{0,30}?" # i18n-allow: input vocab+ r"\b(?:geprompt\w*|gemacht|gesendet|geschickt|angekommen|" # i18n-allow: input vocab+ r"beauftragt|informiert|gebrieft)\b" # i18n-allow: input vocab+ r"|"+ # "da ist nichts passiert" / "es kam nichts an"+ r"\bnichts\b[^.!?]{0,30}?\b(?:passiert|angekommen|gekommen|" # i18n-allow: input vocab+ r"gesendet|da)\b" # i18n-allow: input vocab+ r"|"+ # "das hat nicht geklappt" / "hat nicht funktioniert"+ r"\bhat\b[^.!?]{0,20}?\bnicht\b[^.!?]{0,20}?" # i18n-allow: input vocab+ r"\b(?:geklappt|funktioniert|geklappt)\b" # i18n-allow: input vocab+ r"|"+ # Explicit retry: "mach das nochmal", "versuch es nochmal", "nochmal"+ r"\b(?:nochmal|noch\s+mal|erneut|wiederhol\w*)\b" # i18n-allow: input vocab+ r"|"+ r"\byou\b[^.!?]{0,30}?\b(?:did\s*n[o']?t|have\s*n[o']?t|never)\b"+ r"[^.!?]{0,30}?\b(?:prompt\w*|send|sent|tell|told|brief\w*)\b"+ r"|"+ r"\b(?:that|it|this)\b[^.!?]{0,20}?\b(?:was|were|is)?\s*n[o']?t\b"+ r"[^.!?]{0,20}?\b(?:prompt\w*|sent|delivered|done)\b"+ r"|"+ r"\bnothing\b[^.!?]{0,25}?\b(?:happened|arrived|came\s+through|sent)\b"+ r"|"+ r"\b(?:try\s+again|do\s+it\s+again|once\s+more|again\s+please)\b"+ r"|"+ r"\bno\s+(?:lo\s+)?(?:has|ha)\b[^.!?]{0,30}?" # i18n-allow: input vocab+ r"\b(?:enviado|hecho|mandado|prompteado)\b" # i18n-allow: input vocab+ r"|"+ r"\bno\s+(?:pas[oó]|lleg[oó])\s+nada\b" # i18n-allow: input vocab+ r"|"+ r"\b(?:int[eé]ntalo\s+de\s+nuevo|otra\s+vez|de\s+nuevo)\b" # i18n-allow: input vocab+ r")",+ re.IGNORECASE,+)+++def reports_undelivered(user_text: str) -> bool:+ """Whether the user is saying a pane briefing did not happen, or to retry.++ Answers only the shape of the sentence. Whether there IS a briefing to+ repeat, and whether it actually failed, is the caller's question — the+ workspace holds that evidence (``Terminal.last_prompt_at``), and answering+ it here would mean this module reaching into the registry.+ """+ return bool(_UNDELIVERED_COMPLAINT_RE.search(user_text or ""))++_CLOSE_VERB_RE = re.compile(# ``c(?:e|ie)rr`` carries the Spanish stem change: the imperative people# actually say is "CIERRA todos los terminales", and a ``cerr``-only stem@@ -2278,6 +2344,7 @@ __all__ = ["expects_several","owns_turn","references_recent_fleet",+ "reports_undelivered","spawn_includes_task","spawn_instruction","spawn_vehicle_outranks_workspace",diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 5f37abddf2..a843c9c150 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -6011,6 +6011,21 @@ class BrainManager:# question. ``detect_clarification`` decides when there is one to# ask; it stands down for anything that is not addressing the# workspace.+ # "Du hast es gar nicht gepromptet." names no pane and carries no+ # instruction, so everything above returns nothing — which is how+ # the user ended up saying it twice while Jarvis apologised and+ # promised a delivery it never made (BUG-121). The sentence is only+ # meaningful against the turn before it, so that is where the work+ # comes from.+ # <!-- i18n-allow: quotes the spoken sentence that failed -->+ retry = await self._retry_undelivered_agentic_ide_prompt(+ user_text,+ session=session,+ candidates=candidates,+ language=out_lang,+ )+ if retry is not None:+ return retryreturn self._ask_which_agentic_ide_terminal(user_text, candidates=candidates, language=out_lang)@@ -6187,6 +6202,103 @@ class BrainManager:)return _fanout_reply_line(result, language)+ #: How long a "you never prompted it" complaint may reach back. Bounded to+ #: the running conversation: past this, "do it again" is a fresh request and+ #: replaying a stale sentence into a coding agent would be its own bug.+ _IDE_RETRY_WINDOW_S = 300.0++ async def _retry_undelivered_agentic_ide_prompt(+ self,+ user_text: str,+ *,+ session: Any,+ candidates: list[str],+ language: str,+ ) -> str | None:+ """Deliver the PREVIOUS turn's briefing when the user says it never went.++ Live failure 2026-07-29 17:04 (BUG-121). A briefing for T7 was consumed+ by the navigation gate; Jarvis said it had briefed T7 anyway. The user+ corrected it twice — "Du hast es gar nicht gepromptet", then "Das war+ noch nicht geprompted" — and both corrections produced nothing at all,+ because they name no pane and carry no instruction, so every detector+ returned None and the live model was left to answer alone. It apologised+ and promised a delivery it had no way to make. The third attempt only+ worked because the model happened to call the action tool by itself.+ <!-- i18n-allow: quotes the spoken sentences that failed -->++ A complaint is not proof, so the pane's OWN receipt decides. If+ ``last_prompt_at`` says the briefing did arrive, this answers with the+ clock time instead of typing the sentence a second time — an agent+ briefed twice is two agents' worth of work on one task, and the honest+ answer is what tells the user "it did not happen" from "I did not see it+ happen". Only a pane with no receipt in the window is briefed.+ """+ try:+ from jarvis.agentic_ide import intent as ide_intent+ except Exception: # noqa: BLE001 - optional surface+ return None+ if not ide_intent.reports_undelivered(user_text):+ return None+ previous = self._previous_user_turn_text(use_history=True)+ if not previous:+ return None+ try:+ addressed = ide_intent.detect_all(previous, names=candidates)+ except Exception: # noqa: BLE001 - detection must never break a turn+ return None+ wanted = [+ item.terminal+ for item in addressed+ if item.kind == ide_intent.KIND_PROMPT+ ]+ if not wanted:+ return None++ now = time.time()+ delivered: list[tuple[str, float]] = []+ missing: list[str] = []+ for name in wanted:+ term = session.find(name)+ if term is None:+ continue+ at = getattr(term, "last_prompt_at", None)+ if at is not None and now - float(at) <= self._IDE_RETRY_WINDOW_S:+ delivered.append((name, float(at)))+ else:+ missing.append(name)++ if not missing:+ if not delivered:+ return None+ name, at = delivered[0]+ log.info(+ "Agentic IDE: %s reported undelivered, but %s has a receipt "+ "from %s — answering with the time instead of re-sending",+ user_text[:60],+ name,+ time.strftime("%H:%M:%S", time.localtime(at)),+ )+ return action_phrase(+ "ide_prompt_already_delivered",+ language,+ name=name,+ time=time.strftime("%H:%M", time.localtime(at)),+ )++ log.info(+ "Agentic IDE: retrying an undelivered briefing for %s from the "+ "previous turn",+ ", ".join(missing),+ )+ return await self._deliver_agentic_ide_prompt(+ session=session,+ names=missing,+ utterance=previous,+ instruction="",+ language=language,+ )+def _ask_which_agentic_ide_terminal(self,user_text: str,diff --git a/jarvis/brain/turn_planner.py b/jarvis/brain/turn_planner.pyindex 1123280da9..27aa47b09e 100644--- a/jarvis/brain/turn_planner.py+++ b/jarvis/brain/turn_planner.py@@ -424,6 +424,44 @@ def _is_workspace_turn(text: str, workspace_names: Sequence[str]) -> bool:return False+def _is_workspace_retry(+ text: str, context: Sequence[str], workspace_names: Sequence[str]+) -> bool:+ """Whether this turn says a pane briefing did not happen, or asks to retry.++ A correction of the form "you never prompted it" names no pane, carries no+ instruction and matches no vocabulary here — so the planner routed it+ natively, the live model answered alone, and it apologised for a failure it+ could not see and promised a delivery it could not make (BUG-121, voice+ session 2026-07-29 17:04). The user said it twice; the second time only+ worked by luck, because the model happened to call the action tool by+ itself.++ The sentence is only meaningful against the turn before it, so that is where+ the evidence comes from: the complaint shape from the workspace's own+ detector, the subject from a prior turn that WAS about a pane. Both halves+ are required — a bare "try again" after a weather question is not workspace+ work. Pure regex over in-memory text, no IO and no LLM. The failing live+ sentences are pinned verbatim in+ ``tests/unit/brain/test_agentic_ide_undelivered_retry.py``.+ """+ if not workspace_names or not str(text or "").strip():+ return False+ try:+ from jarvis.agentic_ide.intent import reports_undelivered++ if not reports_undelivered(text):+ return False+ except Exception: # noqa: BLE001 - optional surface, never breaks planning+ return False+ context_text = " ".join(str(item or "") for item in context).strip()+ if not context_text:+ return False+ if len(context_text) > _CONTEXT_MAX_CHARS:+ context_text = context_text[-_CONTEXT_MAX_CHARS:]+ return _is_workspace_turn(context_text, workspace_names)++def is_contextual_follow_up(text: str, context: Sequence[str]) -> bool:"""Return whether ``text`` explicitly refers to the bounded prior context."""normalized = _normalize(text).strip()@@ -485,7 +523,9 @@ def plan_turn(# smalltalk, and a modal asking whether a pane should do something reads as# first-person deliberation. Both would be talked back down into a native# answer the model cannot give.- workspace_turn = _is_workspace_turn(text, workspace_names)+ workspace_turn = _is_workspace_turn(text, workspace_names) or _is_workspace_retry(+ text, context, workspace_names+ )if workspace_turn:reasons.add(TurnReason.WORKSPACE)definition = bool(_DEFINITION_RE.search(normalized))diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.pyindex 2b2804d8e3..3f74d075bb 100644--- a/jarvis/voice/action_phrases.py+++ b/jarvis/voice/action_phrases.py@@ -449,6 +449,19 @@ _PHRASES: dict[str, dict[str, str]] = {"en": "I heard {spoken}. Did you mean {names}?","es": "Entendí {spoken}: ¿te refieres a {names}?",},+ # The user says a briefing never arrived, but the pane's own receipt says it+ # did. Answering with the CLOCK TIME is the point: it is the one thing that+ # lets them tell "it did not happen" from "I did not see it happen", and+ # re-sending on their word would double-brief an agent that is already+ # working (BUG-121).+ "ide_prompt_already_delivered": {+ "de": (+ "{name} hat den Auftrag um {time} bekommen — " # i18n-allow+ "ich schicke ihn nicht doppelt." # i18n-allow+ ),+ "en": "{name} got the task at {time} — I am not sending it twice.",+ "es": "{name} recibió la tarea a las {time}: no la envío dos veces.",+ },# The separator for the final pair of an alternative list ("Maggie or Max").# A phrase entry rather than a literal, so the choice is offered in the# turn's language like every other spoken word.diff --git a/tests/unit/brain/test_agentic_ide_undelivered_retry.py b/tests/unit/brain/test_agentic_ide_undelivered_retry.pynew file mode 100644index 0000000000..4da09a2b4a--- /dev/null+++ b/tests/unit/brain/test_agentic_ide_undelivered_retry.py@@ -0,0 +1,284 @@+"""Recovering from a briefing the user says never arrived.++Live failure 2026-07-29 17:04 (BUG-121). A briefing for T7 was consumed by the+navigation gate, and Jarvis said it had briefed T7 anyway. The user corrected it+twice (both sentences are pinned verbatim as ``COMPLAINT_1`` / ``COMPLAINT_2``+below) — and BOTH corrections produced nothing at all. The flight recorder is+unambiguous: turn 1 routed ``path=native_realtime, reasons=none`` with no+delegate and ``tool_calls=[]``, so no brain ever saw it; the live model+apologised and promised a delivery it had no way to make. Turn 2 routed exactly+the same and only worked because the model happened to call the action tool by+itself. Two wasted turns and an apology are not a recovery path.++Root cause: a correction names no pane and carries no instruction, so every+detector in the workspace returns None and every vocabulary in the planner+misses it. It is only meaningful against the turn before it.++Two layers, matching where the two turns died:++1. ``turn_planner`` inherits ``WORKSPACE`` for a complaint whose PRIOR turn was+ about a pane, so the correction reaches the orchestrator at all.+2. ``_retry_undelivered_agentic_ide_prompt`` delivers the previous turn's+ briefing — but only to a pane whose own receipt (``last_prompt_at``) shows+ nothing arrived. A pane that WAS briefed is answered with the clock time+ instead, because re-sending on an unverified complaint double-briefs a+ working agent.++Deterministic throughout: real detectors, real registry, faked prompt composer.+"""+from __future__ import annotations++import time+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.intent import reports_undelivered+from jarvis.agentic_ide.prompt_composer import ComposedPrompt+from jarvis.agentic_ide.session import Registry+from jarvis.brain.manager import BrainManager+from jarvis.brain.turn_planner import TurnPath, TurnReason, plan_turn+from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from jarvis.core.protocols import BrainMessage+from tests.fakes.fake_pty_manager import FakePtyManager++# The two turns from the live session, verbatim off the flight recorder.+COMPLAINT_1 = "Du hast es gar nicht gepromptet." # i18n-allow: transcript+COMPLAINT_2 = "Das war noch nicht geprompted." # i18n-allow: transcript+ORIGINAL = (+ "Kannst du mal bitte Terminal {a} prompten, dass es einen " # i18n-allow: transcript+ "Deep Dive machen soll, wieso das Resuming Feature nur bei " # i18n-allow: transcript+ "claude Code Sessions funktioniert." # i18n-allow: transcript+)++[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:+ 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:+ 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]:+ assert registry.session is not None+ return [t.name for t in registry.session.terminals if t.prompts_sent > 0]+++def _original(registry: Registry) -> str:+ return ORIGINAL.format(a=_names(registry)[6])+++def _remember(manager: BrainManager, utterance: str) -> None:+ """Put the original request into history, as a real prior turn would."""+ manager._history = [BrainMessage(role="user", content=utterance)]+++# --------------------------------------------------------------------------- #+# The shape detector #+# --------------------------------------------------------------------------- #+++ "text",+ [+ COMPLAINT_1,+ COMPLAINT_2,+ "da ist nichts passiert", # i18n-allow: speech input under test+ "das hat nicht geklappt", # i18n-allow: speech input under test+ "mach das nochmal", # i18n-allow: speech input under test+ "you didn't prompt it",+ "nothing happened",+ "try again",+ "no pasó nada", # i18n-allow: speech input under test+ "inténtalo de nuevo", # i18n-allow: speech input under test+ ],+)+def test_a_complaint_is_recognised(text: str) -> None:+ assert reports_undelivered(text) is True+++ "text",+ [+ # A QUESTION about a delivery must keep reaching the report path.+ "Hast du T7 gepromptet?", # i18n-allow: speech input under test+ "did you prompt T7?",+ # An ordinary briefing is not a complaint.+ "T7 soll einen Deep Dive machen", # i18n-allow: speech input under test+ "zeig mir die Sessions", # i18n-allow: speech input under test+ "wie ist das Wetter", # i18n-allow: speech input under test+ ],+)+def test_an_ordinary_turn_is_not_a_complaint(text: str) -> None:+ assert reports_undelivered(text) is False+++# --------------------------------------------------------------------------- #+# Layer 1 — the correction reaches the orchestrator at all #+# --------------------------------------------------------------------------- #+++def test_the_complaint_routes_to_the_orchestrator() -> None:+ """The live turn routed ``native_realtime, reasons=none`` and died there."""+ plan = plan_turn(+ COMPLAINT_1,+ context=(ORIGINAL.format(a="T7"),),+ workspace_names=("T7",),+ )++ assert plan.path is TurnPath.ORCHESTRATOR+ assert TurnReason.WORKSPACE in plan.reasons+++def test_a_complaint_without_a_workspace_prior_stays_native() -> None:+ """Both halves are required — a bare "try again" is not workspace work."""+ plan = plan_turn(+ COMPLAINT_1,+ context=("wie wird das Wetter morgen",), # i18n-allow: speech input under test+ workspace_names=("T7",),+ )++ assert TurnReason.WORKSPACE not in plan.reasons+++# --------------------------------------------------------------------------- #+# Layer 2 — the previous turn's briefing is actually delivered #+# --------------------------------------------------------------------------- #+++async def test_the_complaint_delivers_the_previous_briefing(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """What the user asked for twice and never got."""+ await _open(registry, tmp_path, 7)+ _remember(manager, _original(registry))++ reply = await manager._run_agentic_ide_fast_path(COMPLAINT_1)++ assert reply is not None+ assert _prompted(registry) == [_names(registry)[6]]+++async def test_a_pane_with_a_receipt_is_not_briefed_twice(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """A complaint is not proof — the pane's own receipt decides.++ Re-sending here would put two briefings into an agent that is already+ working, so the honest answer is the clock time.+ """+ await _open(registry, tmp_path, 7)+ _remember(manager, _original(registry))+ assert registry.session is not None+ term = registry.session.find(_names(registry)[6])+ assert term is not None+ term.last_prompt_at = time.time() - 30.0++ reply = await manager._run_agentic_ide_fast_path(COMPLAINT_1)++ assert reply is not None+ assert _prompted(registry) == []+ assert _names(registry)[6] in reply+++async def test_a_stale_receipt_does_not_block_a_retry(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """Beyond the window the receipt is from another conversation."""+ await _open(registry, tmp_path, 7)+ _remember(manager, _original(registry))+ assert registry.session is not None+ term = registry.session.find(_names(registry)[6])+ assert term is not None+ term.last_prompt_at = time.time() - (manager._IDE_RETRY_WINDOW_S + 60.0)++ reply = await manager._run_agentic_ide_fast_path(COMPLAINT_1)++ assert reply is not None+ assert _prompted(registry) == [_names(registry)[6]]+++async def test_a_complaint_with_no_pane_in_the_prior_turn_does_nothing(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """Never replay a sentence that was not about the workspace."""+ await _open(registry, tmp_path, 7)+ _remember(manager, "wie wird das Wetter morgen") # i18n-allow: speech input under test++ reply = await manager._run_agentic_ide_fast_path(COMPLAINT_1)++ assert _prompted(registry) == []+ assert reply is None+++async def test_the_second_complaint_recovers_too(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """The live session's turn 2, which also produced nothing."""+ await _open(registry, tmp_path, 7)+ _remember(manager, _original(registry))++ reply = await manager._run_agentic_ide_fast_path(COMPLAINT_2)++ assert reply is not None+ assert _prompted(registry) == [_names(registry)[6]]