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): give live tools the user's order, not just their last "yes"

rubenluetke10-beep2e8867f2b5b6
diff --git a/jarvis/live/tools.py b/jarvis/live/tools.py
index d1ad8d745c..82303edda9 100644
--- a/jarvis/live/tools.py
+++ b/jarvis/live/tools.py
@@ -40,6 +40,8 @@ _GO_AHEAD_WORDS = frozenset(
}
) # fmt: skip
_APPROVAL_LOCALES = ("de", "en", "es")
+_RECENT_SEGMENTS = 4
+_REQUEST_TEXT_CHARS = 1200
# Declared before every other tool so the size budget never drops them.
_PRIORITY_TOOLS = frozenset({"workspace-orchestrate", "find-app-action", "run-app-action"})
_APPROVAL_NEXT_STEP = (
@@ -99,6 +101,8 @@ class LiveTools:
self.session_id = session_id
self.language = language
self.backend_model = backend_model
+ # Recent user caption segments, newest last (see ``user_text``).
+ self._recent_user: list[str] = []
self.user_text = ""
self.revision = 0
self.cancel_token = CancelToken()
@@ -390,6 +394,35 @@ class LiveTools:
}
return self._result(result)
+ @property
+ def user_text(self) -> str:
+ """The user's latest caption segment: what answers a question just asked."""
+ return self._recent_user[-1] if self._recent_user else ""
+
+ @user_text.setter
+ def user_text(self, text: str) -> None:
+ text = text or ""
+ last = self._recent_user[-1] if self._recent_user else None
+ if last is not None and (text.startswith(last) or last.startswith(text)):
+ self._recent_user[-1] = text # the same segment, transcribed further
+ elif text.strip():
+ self._recent_user = [*self._recent_user[-(_RECENT_SEGMENTS - 1) :], text]
+ elif last is None:
+ self._recent_user = [text]
+
+ @property
+ def request_text(self) -> str:
+ """The user's last few segments together: what a tool was asked to do.
+
+ The latest segment alone is often only the answer to Jarvis's question
+ ("Ja, los"); a tool that checks its task against the user's words then
+ sees nothing of the order and, in spawn_worker's bleed guard, even
+ replaced the task with "Ja, los".
+ """
+ return " ".join(part.strip() for part in self._recent_user if part.strip())[
+ -_REQUEST_TEXT_CHARS:
+ ]
+
def _reads_only(self, name: str, args: dict) -> bool:
"""True for a call that only reads: tool search or a safe-tier tool."""
if name == "discover_tools":
@@ -421,7 +454,7 @@ class LiveTools:
return SupervisorToolRequest(
trace_id=trace,
origin="realtime",
- user_utterance=self.user_text,
+ user_utterance=self.request_text,
cancel_token=self.cancel_token,
config_snapshot={
"output_language": self.language,
diff --git a/tests/contract/test_gpt_live.py b/tests/contract/test_gpt_live.py
index 4f6737bc4d..3977c102b0 100644
--- a/tests/contract/test_gpt_live.py
+++ b/tests/contract/test_gpt_live.py
@@ -1160,3 +1160,19 @@ def test_a_refusal_that_ran_nothing_does_not_block_reconnecting(ledger):
ledger.finish("s", "bye", {"success": False, "executed": False, "error": "Stay on the call."})
resumable, _ = ledger.recovery_state("s")
assert resumable
+
+
+async def test_a_tool_sees_the_order_not_only_the_answer_to_a_question(ledger):
+ # A worker once started with the task "Ja, los": the bleed guard compared
+ # the order with the latest caption segment only.
+ gateway = Gateway()
+ runtime = LiveTools(gateway, ledger, "s", language="en", backend_model="")
+ runtime.user_text = "Write a file that says hello"
+ runtime.user_text = "Write a file that says hello please"
+ runtime.user_text = "Yes, go"
+ assert runtime.user_text == "Yes, go"
+ request = {"name": "write-file", "arguments_json": '{"text":"hello"}'}
+ assert (await runtime.execute("w", "call_tool", request, 0))["success"]
+ utterance = gateway.calls[-1][2].user_utterance
+ assert utterance == "Write a file that says hello please Yes, go"