Skip to content

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.

fix(computer-use): never acknowledge a screen action the machine cannot run

Harald05495c2d2203
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index 6012fac3c8..56b0787aeb 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -7907,12 +7907,56 @@ class BrainManager:
if plan.mode == LocalActionMode.COMPUTER_USE:
tool = self._local_action_tools.get("dispatch_to_harness")
if tool is None:
+ # Never swallow this silently (contract §7): the gate matched a
+ # screen action but the fast path has no dispatcher. Falling
+ # through to the full brain turn is correct — the `computer_use`
+ # router tool carries its own preflight and speaks honestly —
+ # but the drop must be visible in the log, not invisible.
+ log.warning(
+ "CU fast path: 'dispatch_to_harness' is not registered in "
+ "_local_action_tools; handing the request to the brain turn "
+ "instead of running it deterministically (trace=%s)",
+ tid,
+ )
return None
# Resolve the turn language ONCE here (while it is current) for the
- # spoken cost messages, the immediate ACK, and the background
- # readback — the offloaded task runs after the turn returns and must
- # not read the per-turn state itself (live bug 2026-06-15).
+ # availability refusal, the spoken cost messages, the immediate ACK,
+ # and the background readback — the offloaded task runs after the
+ # turn returns and must not read the per-turn state itself (live bug
+ # 2026-06-15).
cu_lang = self._direct_ack_language(user_text)
+ # Availability preflight (GT-19). The harness only works once the
+ # app wired its ComputerUseContext, and that happens only when
+ # [computer_use].enabled AND a vision engine exist (factory.py).
+ # Unwired, every step died deep inside the harness — but the ACK
+ # below had already promised "Mach ich", so the user heard a
+ # commitment, then nothing, then a failure up to 180 s later. Peek
+ # the singleton BEFORE dispatching and refuse immediately and
+ # honestly instead. Same guard the LLM tool path uses
+ # (plugins/tool/computer_use_tool.py::execute).
+ from jarvis.harness.computer_use_context import ( # noqa: PLC0415
+ peek_computer_use_context,
+ )
+ if peek_computer_use_context() is None:
+ log.warning(
+ "CU fast path: computer-use is not wired on this machine "
+ "([computer_use].enabled false or no vision engine); "
+ "refusing the screen action instead of acknowledging it "
+ "(trace=%s)",
+ tid,
+ )
+ return await render_readback(
+ getattr(self, "_readback_composer", None),
+ instruction=(
+ "Desktop control is switched off on this machine, so "
+ "you cannot do anything on the screen right now. It is "
+ "turned on with the config value "
+ "computer_use.enabled=true, followed by a restart."
+ ),
+ language=cu_lang,
+ canned=lambda: action_phrase("cu_not_wired", cu_lang),
+ latency_budget_ms=900,
+ )
# A multi-step CU mission ("navigate to amazon, search, click") needs a
# generous OUTER cap — the harness has its own per-step timeout +
# step-budget + no-progress/consecutive-failure guards, so this is only
diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.py
index dad71e1ab3..ba8f57b1e7 100644
--- a/jarvis/voice/action_phrases.py
+++ b/jarvis/voice/action_phrases.py
@@ -159,6 +159,25 @@ _PHRASES: dict[str, dict[str, str]] = {
"en": "Application '{app}' was not found.",
"es": "No se encontró la aplicación '{app}'.",
},
+ # Computer-use is NOT wired on this machine — the honest counterpart of
+ # ``cu_dispatch_ack`` below, spoken INSTEAD of it. The harness only works
+ # once the app set its ComputerUseContext, and that needs
+ # [computer_use].enabled (false by default) AND a vision engine
+ # (``brain/factory.py``). Unwired, every step died deep inside the harness
+ # long after the ACK had already promised "Mach ich" — the user heard a
+ # commitment, then nothing (GT-19). This says the one thing they can act on.
+ # No Settings toggle exists yet, so the config value is named outright; it is
+ # spoken, so keep it to one fact plus one action and nothing else.
+ "cu_not_wired": {
+ "de": "Die Bildschirmsteuerung ist auf diesem Rechner aus. " # i18n-allow
+ "Schalte sie in der Konfiguration mit computer_use.enabled ein " # i18n-allow
+ "und starte mich einmal neu.", # i18n-allow
+ "en": "Screen control is switched off on this machine. Turn it on in "
+ "the config with computer_use.enabled, then restart me once.",
+ "es": "El control de pantalla está desactivado en este equipo. "
+ "Actívalo en la configuración con computer_use.enabled y "
+ "reiníciame una vez.",
+ },
# Computer-use dispatch — the immediate optimistic ACK.
"cu_dispatch_ack": {
"de": "Mach ich. Ich erledige das direkt am Bildschirm " # i18n-allow
diff --git a/tests/unit/brain/conftest.py b/tests/unit/brain/conftest.py
index dfbb0de8bd..742879fec0 100644
--- a/tests/unit/brain/conftest.py
+++ b/tests/unit/brain/conftest.py
@@ -25,3 +25,29 @@ def _isolate_capability_registry():
with reg._lock: # noqa: SLF001
reg._caps.clear() # noqa: SLF001
reg._caps.update(snapshot) # noqa: SLF001
+
+
+def wired_computer_use():
+ """Declare Computer-Use WIRED for a test that drives the CU fast path.
+
+ The fast path refuses before dispatch when no ``ComputerUseContext`` exists
+ (GT-19) — the same guard the LLM tool path has carried since 2026-07-06.
+ Tests that assert a DISPATCH therefore have to state that this machine has
+ Computer-Use. They drive a fake tool executor and never reach the real
+ harness, so sentinel dependencies are enough. Mirrors the autouse fixture in
+ ``tests/unit/plugins/tool/test_computer_use_tool.py``. Request it explicitly;
+ tests of the unwired path must NOT get it by accident.
+ """
+ from jarvis.harness.computer_use_context import (
+ ComputerUseContext,
+ set_computer_use_context,
+ )
+
+ set_computer_use_context(
+ ComputerUseContext(
+ vision_engine=object(), brain_manager=object(), tool_executor=object(),
+ ),
+ )
+ yield
+ set_computer_use_context(None)
diff --git a/tests/unit/brain/test_computer_use_offload.py b/tests/unit/brain/test_computer_use_offload.py
index 696ec31a0b..c2639b7a03 100644
--- a/tests/unit/brain/test_computer_use_offload.py
+++ b/tests/unit/brain/test_computer_use_offload.py
@@ -18,6 +18,15 @@ from jarvis.brain.local_action_gate import LocalActionMode, LocalActionPlan
from jarvis.brain.manager import BrainManager
[email protected](autouse=True)
+def _wired(wired_computer_use):
+ """Every test in this file exercises the WIRED offload path.
+
+ Unwired, the fast path refuses before dispatch (GT-19) — that half lives in
+ ``test_cu_fast_path_unwired.py``.
+ """
+
+
class _FakeBus:
def __init__(self) -> None:
self.published: list = []
diff --git a/tests/unit/brain/test_cu_fast_path_unwired.py b/tests/unit/brain/test_cu_fast_path_unwired.py
new file mode 100644
index 0000000000..4819b988bb
--- /dev/null
+++ b/tests/unit/brain/test_cu_fast_path_unwired.py
@@ -0,0 +1,157 @@
+"""GT-19: the deterministic Computer-Use fast path never promises what it cannot do.
+
+The fast path used to ACK ("Mach ich") and start the harness in the background
+*before* checking that Computer-Use is actually wired. It is wired only when
+``[computer_use].enabled`` is true AND a vision engine could be built
+(``brain/factory.py`` calls ``set_computer_use_context``). On every other
+machine — the shipped default among them — each harness step then died deep
+inside the loop, so the user heard a commitment, then silence, then a failure up
+to 180 s later.
+
+The LLM tool path has guarded this since 2026-07-06
+(``plugins/tool/computer_use_tool.py::execute``). These tests pin the same guard
+on the deterministic path: no dispatch, and an immediate honest sentence in the
+turn's own language.
+"""
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.brain.local_action_gate import LocalActionMode, LocalActionPlan
+from jarvis.brain.manager import BrainManager
+from jarvis.harness.computer_use_context import set_computer_use_context
+from jarvis.voice.action_phrases import action_phrase
+
+
+class _FakeBus:
+ def __init__(self) -> None:
+ self.published: list = []
+
+ async def publish(self, event) -> None: # noqa: ANN001
+ self.published.append(event)
+
+
+class _RecordingExecutor:
+ """A tool executor that must never be reached on an unwired machine."""
+
+ def __init__(self) -> None:
+ self.calls: list = []
+
+ async def execute(self, tool, args, *, user_utterance, trace_id): # noqa: ANN001
+ self.calls.append(args)
+ return SimpleNamespace(success=True, output={}, error=None)
+
+
[email protected](autouse=True)
+def _unwired_computer_use_context():
+ """No context — Computer-Use is OFF on this machine."""
+ set_computer_use_context(None)
+ yield
+ set_computer_use_context(None)
+
+
+def _make_manager(executor, bus, *, reply_language: str = "auto"):
+ mgr = BrainManager.__new__(BrainManager)
+ mgr._config = SimpleNamespace(
+ local_action=SimpleNamespace(enabled=True, harness_timeout_s=30.0, direct_timeout_s=3.0)
+ )
+ mgr._bus = bus
+ mgr._tool_executor = executor
+ mgr._local_action_tools = {"dispatch_to_harness": object()}
+ mgr._cost_meter = None
+ mgr._reply_language = reply_language
+ mgr._history = []
+ return mgr
+
+
+def _pin_cu_plan(monkeypatch) -> None:
+ plan = LocalActionPlan(
+ mode=LocalActionMode.COMPUTER_USE, harness="computer-use", prompt="open chrome"
+ )
+ monkeypatch.setattr("jarvis.brain.manager.match_local_action", lambda _t: plan)
+
+
+async def test_unwired_computer_use_never_dispatches(monkeypatch) -> None:
+ executor = _RecordingExecutor()
+ mgr = _make_manager(executor, _FakeBus())
+ _pin_cu_plan(monkeypatch)
+
+ await mgr._run_local_action_fast_path("öffne chrome") # i18n-allow: DE voice fixture
+
+ assert not executor.calls, "dispatched to the harness although Computer-Use is off"
+ assert not getattr(mgr, "_cu_background_tasks", set()), (
+ "started a background mission although Computer-Use is off"
+ )
+
+
+async def test_unwired_computer_use_speaks_instead_of_acking(monkeypatch) -> None:
+ """The user hears an honest refusal, not silence and not "Mach ich"."""
+ mgr = _make_manager(_RecordingExecutor(), _FakeBus())
+ _pin_cu_plan(monkeypatch)
+
+ reply = await mgr._run_local_action_fast_path("öffne chrome") # i18n-allow: DE voice fixture
+
+ assert reply, "returned nothing — the user would hear silence"
+ assert reply == action_phrase("cu_not_wired", "de")
+ assert reply != action_phrase("cu_dispatch_ack", "de"), "still promises to do it"
+ # The refusal must be ACTIONABLE, not just honest: it names the switch the
+ # user can actually flip. A generic "can't do that right now" would leave
+ # them with no way forward.
+ assert "computer_use.enabled" in reply
+
+
[email protected]("utterance,lang", [
+ ("öffne chrome", "de"), # i18n-allow: DE language-detection fixture
+ ("open chrome and search for a flight", "en"),
+])
+async def test_unwired_refusal_follows_the_turn_language(
+ monkeypatch, utterance: str, lang: str,
+) -> None:
+ """The refusal is localized by the same resolver as the ACK it replaces."""
+ mgr = _make_manager(_RecordingExecutor(), _FakeBus())
+ _pin_cu_plan(monkeypatch)
+
+ reply = await mgr._run_local_action_fast_path(utterance)
+
+ assert reply == action_phrase("cu_not_wired", lang)
+
+
+def test_cu_not_wired_is_translated_in_every_locale() -> None:
+ """All locales rank equally (contract §1) — none may fall back to German.
+
+ ``action_phrase`` silently serves the German column for a missing language,
+ so a forgotten translation would ship as an untranslated German sentence to
+ an English or Spanish speaker instead of failing loudly here.
+ """
+ from jarvis.voice.action_phrases import _PHRASES
+
+ variants = _PHRASES["cu_not_wired"]
+ assert set(variants) == {"de", "en", "es"}
+ assert len(set(variants.values())) == 3, f"a locale was left untranslated: {variants}"
+ # The actionable half must survive translation in every locale.
+ assert all("computer_use.enabled" in text for text in variants.values())
+
+
+async def test_missing_dispatch_tool_is_logged_not_swallowed(monkeypatch, caplog) -> None:
+ """No dispatcher registered: the turn falls through to the brain, but audibly.
+
+ ``None`` is the correct return (the ``computer_use`` router tool carries its
+ own preflight), yet the drop must leave a trace instead of vanishing.
+ """
+ mgr = _make_manager(_RecordingExecutor(), _FakeBus())
+ mgr._local_action_tools = {}
+ _pin_cu_plan(monkeypatch)
+
+ with caplog.at_level("WARNING", logger="jarvis.brain.manager"):
+ reply = await mgr._run_local_action_fast_path("öffne chrome") # i18n-allow: DE fixture
+
+ assert reply is None
+ assert any("dispatch_to_harness" in record.message for record in caplog.records), (
+ "the dropped fast path left no log line"
+ )
diff --git a/tests/unit/brain/test_explicit_computer_use_routing.py b/tests/unit/brain/test_explicit_computer_use_routing.py
index 581b2b5dcf..b583f28ca3 100644
--- a/tests/unit/brain/test_explicit_computer_use_routing.py
+++ b/tests/unit/brain/test_explicit_computer_use_routing.py
@@ -36,6 +36,16 @@ from jarvis.brain.local_action_gate import (
match_local_action,
)
+
[email protected](autouse=True)
+def _wired(wired_computer_use):
+ """The dispatch half below asserts a real dispatch, so declare CU wired.
+
+ Unwired, the fast path refuses before dispatch (GT-19) — see
+ ``test_cu_fast_path_unwired.py``.
+ """
+
+
# The exact live utterance that broke, plus adjacent explicit-CU phrasings that
# carry NO open verb (so the open-app fallback can never save them).
REPRO_PHRASE = (
diff --git a/tests/unit/brain/test_routing.py b/tests/unit/brain/test_routing.py
index ee3a141df1..049e1951e0 100644
--- a/tests/unit/brain/test_routing.py
+++ b/tests/unit/brain/test_routing.py
@@ -1732,7 +1732,9 @@ async def test_internal_realtime_reply_can_defer_response_event_to_session() ->
@pytest.mark.asyncio
-async def test_local_visual_click_fast_path_dispatches_computer_use() -> None:
+async def test_local_visual_click_fast_path_dispatches_computer_use(
+ wired_computer_use,
+) -> None:
"""Visual target commands offload to the computer-use harness (Wave-4).
The spoken turn ACKs immediately instead of blocking up to ~31 s on the
@@ -1767,7 +1769,7 @@ async def test_local_visual_click_fast_path_dispatches_computer_use() -> None:
@pytest.mark.asyncio
-async def test_local_computer_use_respects_cost_cooldown() -> None:
+async def test_local_computer_use_respects_cost_cooldown(wired_computer_use) -> None:
"""Visual local commands can invoke paid planner work and must honor cooldown."""
manager, executor = _manager_with_local_actions()
manager._cost_meter = _CooldownCostMeter()
diff --git a/tests/unit/brain/test_skill_routing_guard.py b/tests/unit/brain/test_skill_routing_guard.py
index b2983325a7..6356072237 100644
--- a/tests/unit/brain/test_skill_routing_guard.py
+++ b/tests/unit/brain/test_skill_routing_guard.py
@@ -748,6 +748,7 @@ class _FakeHarnessTool:
async def test_open_discord_e2e_dispatches_computer_use_not_refusal(
tmp_path: Path,
+ wired_computer_use,
) -> None:
_seed_plugin_skill(tmp_path, "plugin-discord", "(discord)")
executor = _HarnessDispatchExecutor()