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(voice): speak the actionable reason when a confirmed action fails

Ruben Lütke2dadb352e8f4
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index fff9f0e840..4cd7161e2e 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -6003,7 +6003,14 @@ class BrainManager:
"failed", pending.tool_name, language=pending.lang
)
kind = "done" if getattr(result, "success", False) else "failed"
- return format_confirm_outcome(kind, pending.tool_name, language=pending.lang)
+ return format_confirm_outcome(
+ kind,
+ pending.tool_name,
+ language=pending.lang,
+ detail=(
+ None if kind == "done" else getattr(result, "error", None)
+ ),
+ )
if verdict == "veto":
self._pending_voice_confirm = None
diff --git a/jarvis/plugins/tool/manage_mcp_server.py b/jarvis/plugins/tool/manage_mcp_server.py
index f4e478753a..cc128c74a7 100644
--- a/jarvis/plugins/tool/manage_mcp_server.py
+++ b/jarvis/plugins/tool/manage_mcp_server.py
@@ -204,10 +204,34 @@ class ManageMcpServerTool:
},
)
+ @staticmethod
+ def _unknown_name_error(mcp_state: Any, name: str) -> str:
+ """Name the configured servers so a miss is actionable, not a dead end.
+
+ Forensic 2026-07-13 18:33: "reconnect the GitHub MCP" failed with a
+ bare unknown-name error — GitHub was a marketplace PLUGIN, not an
+ mcp.json server — and the spoken outcome gave the user nothing to
+ correct with.
+ """
+ try:
+ names = sorted(mcp_state.load_config().get("mcpServers", {}).keys())
+ except Exception: # noqa: BLE001 — the base error must still surface
+ names = []
+ configured = ", ".join(names) if names else "none"
+ return (
+ f"no MCP server named {name!r} — configured MCP servers: "
+ f"{configured}. A marketplace plugin (e.g. GitHub) is not an "
+ "MCP server and is managed from the Plugins view."
+ )
+
async def _remove(self, mcp_state: Any, name: str, reason: str) -> ToolResult:
existed = mcp_state.remove_server(name)
if not existed:
- return ToolResult(success=False, output=None, error=f"no MCP server named {name!r}")
+ return ToolResult(
+ success=False,
+ output=None,
+ error=self._unknown_name_error(mcp_state, name),
+ )
was_running = self._is_running(name)
log.info(
"manage-mcp-server: removed %r (was_running=%s) reason=%r",
@@ -225,7 +249,11 @@ class ManageMcpServerTool:
async def _toggle(self, mcp_state: Any, name: str, *, enabled: bool, reason: str) -> ToolResult:
if mcp_state.get_server_entry(name) is None:
- return ToolResult(success=False, output=None, error=f"no MCP server named {name!r}")
+ return ToolResult(
+ success=False,
+ output=None,
+ error=self._unknown_name_error(mcp_state, name),
+ )
mcp_state.set_enabled(name, enabled)
applied_live = False
diff --git a/jarvis/voice/tool_confirmation.py b/jarvis/voice/tool_confirmation.py
index 634757e9c1..fa7b09b768 100644
--- a/jarvis/voice/tool_confirmation.py
+++ b/jarvis/voice/tool_confirmation.py
@@ -109,17 +109,31 @@ _OUTCOME: dict[str, dict[str, str]] = {
}
+_FAILED_DETAIL_MAX_CHARS = 160
+
+
def format_confirm_outcome(
- kind: str, tool_name: str, *, language: str = "de"
+ kind: str, tool_name: str, *, language: str = "de", detail: str | None = None
) -> str:
"""Render the outcome phrase after the user answered a confirmation.
``kind`` ∈ {"done", "vetoed", "timeout", "failed", "unclear"}. ``tool_name``
is accepted for future tool-specific wording; the current phrasing is generic
but always non-empty (AD-OE6) and covers de/en/es.
+
+ ``detail`` is appended only on ``kind="failed"``: a confirmed action that
+ fails with a bare "that didn't work" gives the user nothing to correct
+ with (forensic 2026-07-13 18:33 — the actionable "no MCP server named
+ 'github'" reason was swallowed). The detail is DATA (like a filename),
+ not re-localized phrasing; it is whitespace-collapsed and bounded.
"""
lang = _phrase_lang(language)
table = _OUTCOME.get(kind)
if table is None: # unknown kind — honest, never empty
table = _OUTCOME["failed"]
- return table.get(lang, table[DEFAULT_LOCALE])
+ phrase = table.get(lang, table[DEFAULT_LOCALE])
+ if kind == "failed" and detail:
+ cleaned = " ".join(str(detail).split())[:_FAILED_DETAIL_MAX_CHARS].strip()
+ if cleaned:
+ phrase = f"{phrase} {cleaned}"
+ return phrase
diff --git a/tests/unit/plugins/tool/test_manage_mcp_server.py b/tests/unit/plugins/tool/test_manage_mcp_server.py
new file mode 100644
index 0000000000..c5dde9b45f
--- /dev/null
+++ b/tests/unit/plugins/tool/test_manage_mcp_server.py
@@ -0,0 +1,63 @@
+"""Unknown-name errors from manage-mcp-server must be actionable.
+
+Forensic 2026-07-13 18:33: "reconnect the GitHub MCP" failed with a bare
+"no MCP server named 'github'" — GitHub was a marketplace plugin, not an
+mcp.json server — and the spoken outcome gave the user nothing to correct.
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from jarvis.plugins.tool.manage_mcp_server import ManageMcpServerTool
+
+
+class _FakeMcpState:
+ def __init__(self, servers: dict | None = None) -> None:
+ self._servers = servers or {}
+
+ def load_config(self) -> dict:
+ return {"mcpServers": dict(self._servers)}
+
+ def get_server_entry(self, name: str) -> dict | None:
+ return self._servers.get(name)
+
+ def remove_server(self, name: str) -> bool:
+ return self._servers.pop(name, None) is not None
+
+
+async def test_toggle_unknown_name_lists_configured_servers() -> None:
+ state = _FakeMcpState({"notebooklm": {"enabled": True}, "blender": {}})
+ result = await ManageMcpServerTool()._toggle(
+ state, "github", enabled=True, reason="test"
+ )
+ assert result.success is False
+ assert "github" in result.error
+ assert "notebooklm" in result.error
+ assert "blender" in result.error
+ assert "plugin" in result.error.lower()
+
+
+async def test_remove_unknown_name_lists_configured_servers() -> None:
+ state = _FakeMcpState({"notebooklm": {"enabled": True}})
+ result = await ManageMcpServerTool()._remove(state, "github", "test")
+ assert result.success is False
+ assert "notebooklm" in result.error
+
+
+async def test_unknown_name_error_survives_a_broken_state() -> None:
+ class _BrokenState:
+ def load_config(self):
+ raise RuntimeError("boom")
+
+ def get_server_entry(self, _name):
+ return None
+
+ result = await ManageMcpServerTool()._toggle(
+ _BrokenState(), "github", enabled=True, reason="test"
+ )
+ assert result.success is False
+ assert "github" in result.error
diff --git a/tests/unit/voice/test_tool_confirmation.py b/tests/unit/voice/test_tool_confirmation.py
index 2d82755195..10be7ac6a7 100644
--- a/tests/unit/voice/test_tool_confirmation.py
+++ b/tests/unit/voice/test_tool_confirmation.py
@@ -89,3 +89,26 @@ class TestFormatConfirmOutcome:
def test_every_outcome_covers_all_three_languages(self, kind: str, lang: str) -> None:
msg = format_confirm_outcome(kind, "gmail", language=lang)
assert msg.strip() != ""
+
+ def test_failed_appends_the_actionable_reason(self) -> None:
+ msg = format_confirm_outcome(
+ "failed",
+ "manage-mcp-server",
+ language="de",
+ detail="no MCP server named 'github' — configured MCP servers: notebooklm",
+ )
+ assert "github" in msg
+ assert "notebooklm" in msg
+
+ def test_failed_detail_is_collapsed_and_bounded(self) -> None:
+ msg = format_confirm_outcome(
+ "failed", "gmail", language="en", detail=" a\n\n b " + "x" * 500
+ )
+ assert "\n" not in msg
+ assert len(msg) < 220
+
+ def test_done_never_carries_a_detail(self) -> None:
+ msg = format_confirm_outcome(
+ "done", "gmail", language="en", detail="should not appear"
+ )
+ assert "should not appear" not in msg