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): a spoken yes confirms the pending action instead of hanging up

rubenluetke10-beep7cb1b8b85500
diff --git a/jarvis/live/config.py b/jarvis/live/config.py
index 0ddff98295..a65186a2da 100644
--- a/jarvis/live/config.py
+++ b/jarvis/live/config.py
@@ -34,6 +34,9 @@ class LiveConfig(BaseModel):
"Discover only the tools needed for the current task using a few English "
"keywords; reuse their schemas and still-current results from this conversation. "
"Read tool schemas before calling. Do not bypass denied actions. "
+ "When a call returns confirmation_required, ask the user; after an explicit "
+ "yes call confirm_action with its approval_id. Call end_call only when the "
+ "user asks to hang up. "
"For coding work use workspace-orchestrate: inspect and resolve the current "
"Project/Workspace/agent graph, then send to the returned stable IDs. Explicit "
"project or workspace references override visible context. Do not switch the UI "
diff --git a/jarvis/live/tools.py b/jarvis/live/tools.py
index 6f703e5a30..1543e18f83 100644
--- a/jarvis/live/tools.py
+++ b/jarvis/live/tools.py
@@ -21,6 +21,28 @@ log = logging.getLogger(__name__)
# history inside the 64 KiB message limit of smaller WebRTC clients.
_CATALOG_BYTE_BUDGET = 24_000
_DISCOVERY_PAGE_SIZE = 8
+_BUILTIN_TOOLS = frozenset({"discover_tools", "call_tool", "confirm_action", "end_call"})
+# Whole-utterance approvals, keyed to the locale whose veto patterns must vet
+# them. The session language cannot be used: "auto" resolves to English before
+# anyone speaks, which rejected a German "Ja" and stranded the approval.
+_AFFIRMATIONS = {
+ "yes": "en",
+ "yes please": "en",
+ "confirm": "en",
+ "confirmed": "en",
+ "do it": "en",
+ "ja": "de", # i18n-allow: spoken confirmation vocabulary
+ "ja bitte": "de", # i18n-allow: spoken confirmation vocabulary
+ "mach das": "de", # i18n-allow: spoken confirmation vocabulary
+ "bestätigen": "de", # i18n-allow: spoken confirmation vocabulary
+ "sí": "es",
+ "si": "es",
+ "confirmo": "es",
+}
+_APPROVAL_NEXT_STEP = (
+ "Ask the user to approve this action. After an explicit yes, call confirm_action "
+ "directly (not through call_tool) with this approval_id. A yes is never a hang-up."
+)
def _wire_size(value: Any) -> int:
@@ -212,18 +234,28 @@ class LiveTools:
}
if ":" in name:
prefix, suffix = name.split(":", 1)
- if prefix.isidentifier() and (
- suffix in self._names
- or suffix
- in {
- "discover_tools",
- "call_tool",
- "confirm_action",
- "end_call",
- }
- ):
+ if prefix.isidentifier() and (suffix in self._names or suffix in _BUILTIN_TOOLS):
name = suffix
+ if name == "call_tool" and args.get("name") in _BUILTIN_TOOLS - {"call_tool"}:
+ # Models wrap the session built-ins too. They are not catalog tools,
+ # so the catalog lookup below answered "no longer available".
+ try:
+ inner = json.loads(args.get("arguments_json") or "{}")
+ except ValueError:
+ inner = None
+ if not isinstance(inner, dict):
+ return {"success": False, "error": "Tool arguments must be an object."}
+ name, args = str(args["name"]), inner
if name == "end_call":
+ if self._pending and self._affirmation_locale() is not None:
+ # Live 2026-10-01: after "Ja" to a pending approval the model
+ # called end_call instead of confirm_action and the call dropped.
+ return {
+ "success": False,
+ "error": "The user approved a pending action; they did not ask to hang up.",
+ "approval_ids": list(self._pending),
+ "next_step": "Call confirm_action with the approval_id.",
+ }
self.end_requested = True
return {"success": True, "status": "closing_voice"}
if name == "discover_tools":
@@ -261,27 +293,13 @@ class LiveTools:
approval_id = str(args.get("approval_id", ""))
pending = self._pending.get(approval_id)
- affirmation = re.sub(r"[^\w\s]", "", self.user_text.casefold()).strip()
+ locale = self._affirmation_locale()
if (
pending is None
or self.revision <= pending[3]
- or affirmation
- not in {
- "yes",
- "yes please",
- "confirm",
- "confirmed",
- "do it",
- "ja", # i18n-allow: spoken confirmation vocabulary
- "ja bitte", # i18n-allow: spoken confirmation vocabulary
- "mach das", # i18n-allow: spoken confirmation vocabulary
- "bestätigen", # i18n-allow: spoken confirmation vocabulary
- "sí",
- "si",
- "confirmo",
- }
+ or locale is None
or len(self.user_text.split()) > 5
- or classify_response(self.user_text, language=self.language) != "confirm"
+ or classify_response(self.user_text, language=locale) != "confirm"
):
return {"success": False, "error": "This action has not been explicitly approved."}
trace, _, _, _ = self._pending.pop(approval_id)
@@ -343,9 +361,14 @@ class LiveTools:
"tool": canonical,
"arguments": args,
"impact": result.output,
+ "next_step": _APPROVAL_NEXT_STEP,
}
return self._result(result)
+ def _affirmation_locale(self) -> str | None:
+ """Locale of a whole-utterance approval in the latest user text, else None."""
+ return _AFFIRMATIONS.get(re.sub(r"[^\w\s]", "", self.user_text.casefold()).strip())
+
def _request(self, trace: UUID) -> SupervisorToolRequest:
return SupervisorToolRequest(
trace_id=trace,
diff --git a/tests/contract/test_gpt_live.py b/tests/contract/test_gpt_live.py
index 955f8c14b8..81e94197d9 100644
--- a/tests/contract/test_gpt_live.py
+++ b/tests/contract/test_gpt_live.py
@@ -213,6 +213,75 @@ async def test_approval_requires_new_unambiguous_confirmation(ledger):
assert len(gateway.calls) == 2
+class _ApprovalGateway(Gateway):
+ async def execute(self, name, args, request):
+ from jarvis.safety.tool_executor import VOICE_CONFIRM_SENTINEL
+
+ self.calls.append((name, args, request))
+ return ToolResult(False, {}, VOICE_CONFIRM_SENTINEL)
+
+ async def execute_confirmed(self, trace, request):
+ self.calls.append(("confirmed", {}, request))
+ return ToolResult(True, {"verified": True})
+
+
+async def _pending_approval(runtime):
+ request = {"name": "write-file", "arguments_json": '{"text":"hello"}'}
+ result = await runtime.execute("c", "call_tool", request, 0)
+ assert "confirm_action" in result["next_step"]
+ runtime.revision = 1
+ return result["approval_id"]
+
+
[email protected]("answer", ["Ja.", "Sí", "Yes"])
+async def test_approval_in_any_locale_survives_an_auto_session_language(ledger, answer):
+ # Live 2026-10-01: an "auto" session resolves to English, which rejected "Ja".
+ gateway = _ApprovalGateway()
+ runtime = LiveTools(gateway, ledger, "s", language="en", backend_model="")
+ approval = await _pending_approval(runtime)
+ runtime.user_text = answer
+ result = await runtime.execute("ok", "confirm_action", {"approval_id": approval}, 1)
+ assert result["success"]
+ assert gateway.calls[-1][0] == "confirmed"
+
+
+async def test_veto_still_wins_over_a_listed_affirmation(ledger):
+ runtime = LiveTools(_ApprovalGateway(), ledger, "s", language="en", backend_model="")
+ approval = await _pending_approval(runtime)
+ runtime.user_text = "nein"
+ result = await runtime.execute("no", "confirm_action", {"approval_id": approval}, 1)
+ assert not result["success"]
+
+
+async def test_yes_to_a_pending_approval_does_not_hang_up(ledger):
+ gateway = _ApprovalGateway()
+ runtime = LiveTools(gateway, ledger, "s", language="en", backend_model="")
+ approval = await _pending_approval(runtime)
+ runtime.user_text = "Ja"
+ refused = await runtime.execute("bye", "end_call", {}, 1)
+ assert not refused["success"]
+ assert refused["approval_ids"] == [approval]
+ assert not runtime.end_requested
+ runtime.user_text = "Leg auf" # i18n-allow: spoken hang-up request
+ runtime.revision = 2
+ assert (await runtime.execute("bye2", "end_call", {}, 2))["success"]
+ assert runtime.end_requested
+
+
+async def test_built_ins_wrapped_in_call_tool_still_run(ledger):
+ gateway = _ApprovalGateway()
+ runtime = LiveTools(gateway, ledger, "s", language="en", backend_model="")
+ approval = await _pending_approval(runtime)
+ runtime.user_text = "ja bitte" # i18n-allow: spoken confirmation vocabulary
+ wrapped = {"name": "confirm_action", "arguments_json": f'{{"approval_id":"{approval}"}}'}
+ assert (await runtime.execute("w", "call_tool", wrapped, 1))["success"]
+ assert gateway.calls[-1][0] == "confirmed"
+
+
@pytest.mark.asyncio
async def test_gemini_native_core_does_not_dispatch_a_second_model(ledger):
runtime = LiveTools(Gateway(), ledger, "s", language="en", backend_model="")