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(computer-use): honest ToolResult instead of RuntimeError when the CU context is not wired
Ruben Lütke84c84abcf7a1
diff --git a/jarvis/harness/computer_use_context.py b/jarvis/harness/computer_use_context.pyindex adc2fc0194..92b3fd86ca 100644--- a/jarvis/harness/computer_use_context.py+++ b/jarvis/harness/computer_use_context.py@@ -309,3 +309,13 @@ def get_computer_use_context() -> ComputerUseContext:"before the first dispatch.",)return _CONTEXT+++def peek_computer_use_context() -> "ComputerUseContext | None":+ """Non-raising read of the global CU context (None when never wired).++ Lets callers degrade honestly on machines where [computer_use].enabled is+ false or the vision engine failed to build, instead of hitting the+ RuntimeError in get_computer_use_context().+ """+ return _CONTEXTdiff --git a/jarvis/plugins/tool/computer_use_tool.py b/jarvis/plugins/tool/computer_use_tool.pyindex b16d6050bc..fcdf759c22 100644--- a/jarvis/plugins/tool/computer_use_tool.py+++ b/jarvis/plugins/tool/computer_use_tool.py@@ -30,6 +30,7 @@ from jarvis.brain.local_action_gate import HARNESS_NAMEfrom jarvis.core.bus import EventBusfrom jarvis.core.events import AnnouncementRequestedfrom jarvis.core.protocols import ExecutionContext, ToolResult+from jarvis.harness.computer_use_context import peek_computer_use_contextfrom jarvis.harness.manager import HarnessManagerfrom jarvis.plugins.tool.dispatch_to_harness import DispatchToHarnessToolfrom jarvis.voice.action_phrases import (@@ -160,6 +161,24 @@ class ComputerUseTool:goal = (args.get("goal") or "").strip()if not goal:return ToolResult(success=False, output=None, error="goal missing")+ # Fresh-machine honesty (2026-07-06): computer_use stays in ROUTER_TOOLS+ # unconditionally (ADR-0011), but the CU context is only wired when+ # [computer_use].enabled AND a vision engine exist (factory.py). On a+ # fresh install (the shipped default is disabled) every dispatch used+ # to die deep inside the harness with "RuntimeError: ComputerUseHarness+ # context not set". Peek the singleton BEFORE dispatching so an unwired+ # machine gets an honest, actionable ToolResult instead of a crash.+ if peek_computer_use_context() is None:+ return ToolResult(+ success=False,+ output=None,+ error=(+ "computer-use is not active on this machine: [computer_use].enabled "+ "is false (the shipped default) or no vision engine could be built. "+ "Tell the user desktop control is currently OFF and can be switched "+ "on in Settings; do not retry this tool in this turn."+ ),+ )# Wave 0 (frontier-speed, 2026-06-09): with a bus wired (production),# the mission runs as a BACKGROUND task and the brain turn gets an# immediate ACK. Run inline, the mission would live inside the braindiff --git a/tests/unit/plugins/tool/test_computer_use_tool.py b/tests/unit/plugins/tool/test_computer_use_tool.pyindex d1d50753df..56ca507dd2 100644--- a/tests/unit/plugins/tool/test_computer_use_tool.py+++ b/tests/unit/plugins/tool/test_computer_use_tool.py@@ -18,10 +18,37 @@ import asyncioimport uuidfrom collections.abc import AsyncIterator+import pytest+from jarvis.core.protocols import ExecutionContext, HarnessResult, HarnessTask+from jarvis.harness.computer_use_context import (+ ComputerUseContext,+ set_computer_use_context,+)from jarvis.plugins.tool.computer_use_tool import _ctx_output_language[email protected](autouse=True)+def _wired_computer_use_context():+ """Every test in this file below exercises dispatch/ack/background behaviour+ through a FAKE ``HarnessManager`` — it never reaches the real ``computer-use``+ harness plugin, so the actual CU dependencies (vision engine, brain manager,+ tool executor) are irrelevant here; sentinels are enough. Wiring a context+ keeps the fresh-machine honesty gate at the top of ``ComputerUseTool.execute``+ (see ``test_execute_without_context_returns_honest_failure`` below) from+ blocking every other test, which intentionally exercises the WIRED path. The+ unwired path is tested in isolation by that one test, which overrides this+ fixture's context with ``set_computer_use_context(None)`` for its own scope.+ """+ set_computer_use_context(+ ComputerUseContext(+ vision_engine=object(), brain_manager=object(), tool_executor=object(),+ ),+ )+ yield+ set_computer_use_context(None)++def _lang_ctx(user_utterance: str, config: dict) -> ExecutionContext:return ExecutionContext(trace_id=uuid.uuid4(),@@ -461,6 +488,35 @@ async def test_completion_carries_cu_tool_source_layer_for_history_mirror() -> N)+# ---------------------------------------------------------------------------+# Fresh-machine honesty (2026-07-06). On a fresh install [computer_use].enabled+# defaults to false, so the CU context is never wired — but computer_use stays+# in ROUTER_TOOLS (ADR-0011). Before this fix every dispatch on such a machine+# died deep inside the harness with "RuntimeError: ComputerUseHarness context+# not set". The tool must instead recognize the unset context BEFORE dispatch+# and answer with an honest, actionable ToolResult.+# ---------------------------------------------------------------------------+++async def test_execute_without_context_returns_honest_failure() -> None:+ """Fresh machine: [computer_use].enabled=false -> context never wired.+ The tool must degrade to an actionable ToolResult, never raise."""+ from jarvis.plugins.tool.computer_use_tool import ComputerUseTool++ # Override the file's autouse "wired" fixture for this test's scope only.+ set_computer_use_context(None)+ try:+ tool = ComputerUseTool(bus=None, manager=_FakeHarnessManager())+ result = await tool.execute({"goal": "open the browser"}, _ctx())++ assert result.success is False+ assert "not active" in (result.error or "").lower()+ assert "settings" in (result.error or "").lower()+ finally:+ # Global singleton — never leak a wired/unwired state into other tests.+ set_computer_use_context(None)++async def test_success_readback_falls_back_to_done_without_proof() -> None:from jarvis.plugins.tool.computer_use_tool import ComputerUseToolfrom jarvis.voice.action_phrases import action_phrase