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(realtime): a question is not answered with "Erledigt." (BUG-160)

Haralda4dbfea8beb6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad24ed341a..8c6ca5aaa9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,24 @@ versioning per [SemVer](https://semver.org/).
### Fixed
+- **A question is no longer answered with "Erledigt."** In a live call, asking
+ something could come back as that one word — a report that a job was
+ finished, for a job nobody had given, while the actual answer was thrown
+ away seconds later. Two faults stacked up. Gemini and Vertex Live end their
+ generation when they hand out a tool call and start a fresh one for the
+ spoken answer; the adapter meant to swallow that in-between marker but
+ looked for the tool call in the wrong message, so it never once did — 39 of
+ those markers in a single day's log, every one of them read as "the provider
+ has gone silent". On top of that, the recovery for a silent provider treated
+ a finished web search like a finished errand: the search carries no sentence
+ to say, only the material for one, and the recovery said "done" and dropped
+ the material. Now the adapter waits for the generation that actually speaks,
+ and a lookup that came back with something says what it found instead of
+ reporting a completed task — with "I have the information but couldn't read
+ it out just now" as the honest floor, and "I didn't find anything on that"
+ when the search really was empty. A wordless action still reports done, as
+ it should.
+
- **A window that never received a page is caught too.** The blank-window
watchdog shipped in 1.5.0 lives in `index.html`, so it can only act once a
page has arrived — and the window the maintainer kept seeing had none: a
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 4d8e47204f..38489dd83e 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -11201,3 +11201,73 @@ fake no longer pretends the frozen preflight updates in-process.
rebuild remains a new app to TCC. A Developer-ID signing identity is the
structural fix; until then a rebuild costs the user one round of re-granting,
now visible in the log and explained in the UI.
+
+---
+
+## BUG-160: a spoken question is answered with "Erledigt." and the real answer is thrown away — every Gemini/Vertex Live tool call fakes a mute provider (CRITICAL, FIXED 2026-08-20)
+
+**Symptom (maintainer, reported 2026-08-20).** In a live call, questions came
+back as the single word "Erledigt." — a completion report for a job that was
+never given. The maintainer had asked something, not ordered anything, and had
+no idea what was supposed to have been completed. The answer he did ask for was
+never spoken.
+
+**Root causes (two independent defects, one on top of the other).**
+
+1. *The Gemini/Vertex Live adapter never withheld a tool-call turn boundary.*
+ Gemini closes its generation when it hands out a function call, then opens a
+ NEW generation carrying the spoken answer once the tool result arrives. The
+ adapter has always meant to swallow that intermediate boundary, but the
+ check read the PER-MESSAGE `function_calls` — and the server sends the tool
+ call and the boundary in SEPARATE messages. The guard therefore never fired
+ once: in one day's desktop log, 39 boundaries emitted, 0 withheld. The
+ session took every one of them for a provider that had gone mute, ran its
+ empty-turn recovery, sent a "say the tool result out loud" retry prompt
+ (which on its own caused duplicate searches), and then spoke its own
+ fallback line over the answer that was still being rendered. The OpenAI
+ adapter has always done this correctly with a response-scoped flag; the two
+ transports were simply not on the same contract.
+
+2. *The direct-tool recovery reported a finished LOOKUP as a finished JOB.*
+ `_direct_tool_fallback_text` reads each result for a speakable line.
+ `search_web` has none by design — its whole point is that the model
+ synthesizes the answer from the hits — so a successful search fell through
+ to `action_phrase("cu_done")`, which is "Erledigt." / "Done." / "Listo.".
+ Two lies in nine characters: nothing was completed, and the retrieved
+ answer was dropped on the floor. Live evidence 2026-08-20 19:32:41:
+ `transcript=9 chars` on the surface-TTS fallback, followed 2.1 s later by
+ the model's real 6.5 s answer being withheld as a duplicate. In one day:
+ 20 spurious retries, 15 spoken fallbacks, 25 discarded answers.
+
+**Fixes.**
+
+1. `jarvis/plugins/realtime/gemini_live.py` decides the withhold on the
+ per-GENERATION function-call counter, read before the boundary logger
+ resets it. A generation that produced NOTHING after the tool result still
+ emits its boundary, so the genuine-mute recovery is untouched; if the model
+ never generates again, the session's own turn-stall watchdog closes the turn
+ honestly rather than the adapter faking a boundary.
+2. `jarvis/realtime/session.py` decides "done" on EVIDENCE, not on the tool's
+ name, because a name is ambiguous (`gmail` sends mail and lists it). A
+ lookup-class result diverts from `cu_done` only once its payload shows
+ something the user has not heard: content came back → the facts go to the
+ honesty-bound readback composer and answer the question, with
+ `lookup_unspoken` ("I have the information but couldn't read it out just
+ now") as the floor; an explicitly EMPTY result set → `lookup_empty`
+ ("I didn't find anything on that"); a bare receipt with no payload →
+ `cu_done` stands, unchanged.
+
+**Class rule.** "Done." is a CLAIM about work, and a question is not work. Any
+recovery line that a retrieval tool can reach must be able to tell an answer
+from a receipt, and must never trade the user's answer for a status word. The
+second half of the rule is older and was broken here too: a boundary a
+transport emits for its own protocol reasons is not evidence about what the
+user heard.
+
+**Guards.** `tests/unit/realtime/test_gemini_live.py::test_tool_call_suppresses_turn_complete_from_a_later_message`
+(the live message split the old per-message check could never see),
+`::test_a_real_mute_after_a_tool_still_reaches_the_session` (the
+counterweight — suppression must not cost the mute recovery), and
+`tests/unit/realtime/test_lookup_never_reports_done.py` (a finished search is
+never "Erledigt."; an empty one says so; a wordless ACTION still reports done;
+the facts handed to the composer carry the content and never the URLs).
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.py
index bc729462da..8da3709f2e 100644
--- a/jarvis/plugins/realtime/gemini_live.py
+++ b/jarvis/plugins/realtime/gemini_live.py
@@ -468,16 +468,40 @@ class _GeminiLiveSession:
type="usage", usage=self._pending_usage
)
self._pending_usage = None
+ # A generation that handed out a function call has NOT
+ # finished the turn: Gemini closes it so the tool result
+ # can travel, then opens a NEW generation carrying the
+ # spoken answer. The withhold below has stood since the
+ # adapter was written, but it read the PER-MESSAGE
+ # ``function_calls`` — and the server sends the tool call
+ # and this boundary in SEPARATE messages, so it never
+ # once fired (live 2026-08-20: 39 boundaries emitted, 0
+ # withheld). The session took every one of them for a
+ # mute provider, spoke the direct-tool fallback line
+ # ("Erledigt.") over the user's question, and then
+ # withheld the real answer that arrived two seconds
+ # later. The per-GENERATION counter is the evidence that
+ # survives the message split; it is read here because
+ # ``_log_generation_boundary`` resets it. The OpenAI
+ # adapter has always done this correctly with its
+ # response-scoped ``_response_had_tool_calls`` flag —
+ # this brings Gemini/Vertex Live to the same contract.
+ # If the model never generates again, the session's own
+ # turn-stall watchdog closes the turn honestly; it is
+ # not this adapter's job to fake a boundary.
+ tool_generation = bool(function_calls) or (
+ self._gen_function_calls > 0
+ )
self._log_generation_boundary(
kind=(
"turn complete (function call, boundary "
"withheld)"
- if function_calls
+ if tool_generation
else "turn complete"
),
reason=reason_name,
)
- if not function_calls:
+ if not tool_generation:
yield _ProviderEvent(type="turn_complete")
go_away = getattr(message, "go_away", None)
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 227fafbe1e..08669c50f4 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -272,6 +272,12 @@ _FAILURE_READBACK_BUDGET_MS = 900
# ("Unknown skill: X. Installed skills: a, b, c, …"); one sentence's worth is
# what a person can act on, the rest is a wall of speech.
_FAILURE_REASON_MAX_CHARS = 160
+# Ground truth handed to the composer that answers from a lookup nobody spoke
+# (``_lookup_facts``). Three search variants return up to fifteen rows between
+# them; the answer to a spoken question lives in the first few, and everything
+# past that is prompt weight paid on the turn-critical path for nothing.
+_LOOKUP_FACT_MAX_ITEMS = 5
+_LOOKUP_FACT_MAX_CHARS = 320
# A delegated turn fails for a handful of KNOWN internal reasons, and the raw
# internal strings are engineering vocabulary ("No configured Tool Model
# completed the delegated turn.") that must never be spoken. Each cause maps to
@@ -1321,6 +1327,76 @@ def _speakable_failure_reason(result: object) -> str:
return cut.rstrip(" ,;.") + "…"
+def _lookup_facts(
+ lookups: list[tuple[str, dict[str, Any]]],
+) -> dict[str, object]:
+ """The retrieved content of a turn, bounded and voice-shaped.
+
+ Ground truth for the honesty-bound composer in
+ :meth:`RealtimeVoiceSession._wordless_success_line`: the model may rephrase
+ ONLY what is in here, so this must carry the answer and nothing else. Every
+ retrieval tool in the tree returns its hits as ``{"title", "snippet",
+ "url"}`` rows under ``output["results"]`` (web search, the weather branch,
+ the DDG instant-answer box), which is the shape read first; a tool that
+ answers with a plain string or a ``text`` / ``summary`` / ``content`` field
+ is read next.
+
+ URLs never travel — they are unspeakable and the scrubber would strip them
+ anyway. A raw ``str(dict)`` of an unknown payload never travels either:
+ that is exactly the data-structure dump the output filter exists to catch,
+ and feeding one to a composer only moves the leak one step upstream. An
+ unrecognized shape simply yields nothing, and the caller speaks its honest
+ canned floor instead. Pure string work, no LLM (AP-11).
+ """
+ items: list[str] = []
+ for _name, result in lookups:
+ output = result.get("output")
+ rows = output.get("results") if isinstance(output, dict) else None
+ if isinstance(rows, list):
+ for row in rows:
+ if not isinstance(row, dict):
+ continue
+ title = " ".join(str(row.get("title") or "").split())
+ snippet = " ".join(str(row.get("snippet") or "").split())
+ text = f"{title}: {snippet}" if title and snippet else title or snippet
+ if text:
+ items.append(text[:_LOOKUP_FACT_MAX_CHARS])
+ continue
+ if isinstance(output, str):
+ if text := " ".join(output.split()):
+ items.append(text[:_LOOKUP_FACT_MAX_CHARS])
+ continue
+ if isinstance(output, dict):
+ for field in ("summary", "text", "content", "answer"):
+ if text := " ".join(str(output.get(field) or "").split()):
+ items.append(text[:_LOOKUP_FACT_MAX_CHARS])
+ break
+ if not items:
+ return {}
+ return {"retrieved": items[:_LOOKUP_FACT_MAX_ITEMS]}
+
+
+def _reported_empty_results(
+ lookups: list[tuple[str, dict[str, Any]]],
+) -> bool:
+ """True when a lookup explicitly came back with an empty result set.
+
+ The difference between "I found nothing" and "there was nothing to find
+ out": a payload that CARRIES a ``results`` collection and left it empty has
+ searched and come up dry, while a payload with no collection at all is a
+ receipt that was never about content. Only the first may be reported as an
+ empty answer — guessing on the second would invent a search that never ran.
+ """
+ for _name, result in lookups:
+ output = result.get("output")
+ if not isinstance(output, dict) or "results" not in output:
+ continue
+ rows = output.get("results")
+ if isinstance(rows, list | tuple) and not rows:
+ return True
+ return False
+
+
def _direct_tool_result_retry_prompt(
*, language: str, unfinished: bool = False
) -> str:
@@ -8314,6 +8390,129 @@ class RealtimeVoiceSession:
return cleaned
return ""
+ def _result_is_informational(self, name: str, result: dict[str, Any]) -> bool:
+ """True when the result is CONTENT the user is still owed, not a receipt.
+
+ ``cu_done`` — "Erledigt." / "Done." / "Listo." — is a CLAIM: the thing
+ you asked for has been carried out. That is honest for a tool that ACTED
+ (an app was opened, a message was sent) and a lie for a tool that LOOKED
+ SOMETHING UP, where the user asked a question and the answer is sitting
+ unspoken in the payload. Live forensic 2026-08-20 19:32:41: a
+ ``search_web`` call about Y Combinator succeeded, the live model went
+ quiet, and the recovery spoke "Erledigt." — a completion report for a
+ job the maintainer never gave, with the retrieved answer dropped on the
+ floor.
+
+ Two independent signals, either one sufficient, so the rule covers the
+ CLASS rather than the one shipped search tool:
+
+ * the payload carries ``answer_instruction`` — the explicit "turn this
+ data into the answer yourself" marker a retrieval tool sets for the
+ model, which is by definition an answer nobody has spoken yet; and
+ * the tool's activity class is SEARCH or READ, the same coarse
+ name-based classification the progress lines already run on, which
+ reaches any registry's ``*_search`` / ``*_list`` / ``*_get`` /
+ ``*_lookup`` tool, MCP servers and plugins included.
+
+ Deterministic, no LLM (AP-11).
+ """
+ from jarvis.voice.instant_ack import ToolActivity, classify_tool_activity
+
+ output = result.get("output")
+ if isinstance(output, dict) and output.get("answer_instruction"):
+ return True
+ return classify_tool_activity(name) in (
+ ToolActivity.SEARCH,
+ ToolActivity.READ,
+ )
+
+ async def _wordless_success_line(
+ self, succeeded: list[tuple[str, dict[str, Any]]]
+ ) -> str:
+ """The spoken line for tools that worked but handed back no sentence.
+
+ An ACTION that ran is reported with ``cu_done``; that is what the phrase
+ is for and it stays untouched here. A LOOKUP that ran is not: the user
+ asked a question, the answer is in the payload, and "Erledigt." both
+ claims a job that was never given and throws the answer away.
+
+ So the retrieved facts go through the same composer every other readback
+ uses — honesty-bound, so it may only rephrase what the tool actually
+ returned, bounded by the live-path budget, breaker-guarded. The floor
+ under it is not the completion claim but a line that says WHY the answer
+ is missing and offers the retry (the maintainer's standing rule: a
+ failure the user hears always names its cause). A mixed turn counts as a
+ lookup: one unspoken answer outweighs any number of silent receipts.
+
+ The decision runs on EVIDENCE, not on the tool's name alone, because a
+ name is genuinely ambiguous — ``gmail`` sends mail and lists it, and
+ only one of those is a question waiting on an answer. So a lookup-class
+ tool diverts from ``cu_done`` only once its payload shows something the
+ user has not heard:
+
+ * content came back -> answer the question from it;
+ * the tool reported an EMPTY result set -> say nothing was found, which
+ is the honest answer to the question and not a completion claim;
+ * the payload carried nothing at all (``{}``, a bare receipt) -> there
+ is no withheld answer, so ``cu_done`` stands.
+ """
+ from jarvis.voice.action_phrases import action_phrase
+ from jarvis.voice.contextual_readback import render_readback
+
+ language = self._language
+ lookups = [
+ (name, result)
+ for name, result in succeeded
+ if self._result_is_informational(name, result)
+ ]
+ if not lookups:
+ # Everything that ran ACTED. "Erledigt." is the honest report.
+ return action_phrase("cu_done", language)
+
+ canned = lambda: action_phrase("lookup_unspoken", language) # noqa: E731
+ facts = _lookup_facts(lookups)
+ if not facts:
+ if _reported_empty_results(lookups):
+ # The lookup ran and came back with nothing. "Erledigt." would
+ # report a finished job; the user asked a question and the
+ # honest answer to it is that there was no hit.
+ return action_phrase("lookup_empty", language)
+ # A bare receipt with no payload: nothing was withheld from the
+ # user, so the ordinary completion line is the truthful one.
+ return action_phrase("cu_done", language)
+ try:
+ line = await render_readback(
+ getattr(self._brain, "_readback_composer", None),
+ instruction=(
+ "The user asked a question, the lookup that answers it "
+ "succeeded, and the live model never spoke the answer. "
+ "Answer the question in one or two short spoken sentences "
+ "using ONLY the retrieved facts."
+ ),
+ language=language,
+ canned=canned,
+ facts=facts,
+ honesty_bound=True,
+ latency_budget_ms=_FAILURE_READBACK_BUDGET_MS,
+ )
+ except Exception: # noqa: BLE001 — a readback must never break the call
+ log.debug(
+ "realtime[%s] lookup readback composition failed",
+ self.session_id,
+ exc_info=True,
+ )
+ line = ""
+ line = (line or "").strip()
+ if not line:
+ return canned()
+ # This text is built from web-retrieved prose, so it takes the same
+ # regex scrub as every other direct-to-surface line (ADR-0010, AP-11)
+ # rather than trusting the consumer to do it.
+ scrubbed = scrub_for_voice(line, language=language)
+ if is_harmless_scrub_residue(scrubbed):
+ return canned()
+ return scrubbed.cleaned.strip() or canned()
+
async def _direct_tool_fallback_text(self) -> tuple[str, bool]:
"""Return one speakable line for EVERY tool the turn ran.
@@ -8338,9 +8537,15 @@ class RealtimeVoiceSession:
"""
from jarvis.voice.action_phrases import action_phrase
- results = [dict(result) for _name, result in self._direct_tool_results]
+ # Pairs, not bare payloads: the tool's NAME is half the evidence for
+ # whether its silent success may be reported as "Erledigt."
+ # (:meth:`_result_is_informational`).
+ results = [
+ (str(name or ""), dict(result))
+ for name, result in self._direct_tool_results
+ ]
# Rule 1: policy blocks carry model instructions, not user-facing text.
- speakable = [r for r in results if not r.get("blocked")]
+ speakable = [pair for pair in results if not pair[1].get("blocked")]
if not speakable:
# Every call the model made was gated away. Nothing ran, nothing
# broke — and nothing is missing either, which is why this is NOT
@@ -8353,26 +8558,26 @@ class RealtimeVoiceSession:
# turn answered inline.
return action_phrase("actions_not_requested", self._language), False
- succeeded = [r for r in speakable if r.get("success")]
- failed = [r for r in speakable if not r.get("success")]
+ succeeded = [pair for pair in speakable if pair[1].get("success")]
+ failed = [pair[1] for pair in speakable if not pair[1].get("success")]
# A confirmation question owns the turn — it is the one line that still
# needs an answer from the user, so it outranks any status summary.
- for result in speakable:
+ for _name, result in speakable:
if result.get("confirmation_required"):
if text := self._speakable_result_text(result):
return text, bool(result.get("success"))
spoken_parts = [
text
- for result in succeeded
+ for _name, result in succeeded
if (text := self._speakable_result_text(result))
]
if succeeded and not failed:
if spoken_parts:
return " ".join(spoken_parts), True
- return action_phrase("cu_done", self._language), True
+ return await self._wordless_success_line(succeeded), True
if not succeeded:
# Rule 3: nothing worked. Name every cause the tools reported.
@@ -8389,7 +8594,9 @@ class RealtimeVoiceSession:
# Rule 2: partial success. Say what happened, then what did not — the
# turn is NOT reported as a failure, because work was actually done.
- done = " ".join(spoken_parts) or action_phrase("cu_done", self._language)
+ done = " ".join(spoken_parts) or await self._wordless_success_line(
+ succeeded
+ )
shortfall = await self._failure_line(
failed[0] if len(failed) == 1 else self._merged_failure(failed),
situation=(
diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.py
index 4c4f72ed16..e7f664e7e4 100644
--- a/jarvis/voice/action_phrases.py
+++ b/jarvis/voice/action_phrases.py
@@ -47,6 +47,33 @@ _PHRASES: dict[str, dict[str, str]] = {
"en": "Done.",
"es": "Listo.",
},
+ # The lookup ran, its answer never got spoken, and nothing could be built
+ # from what it returned. The floor under ``_wordless_success_line`` — and
+ # deliberately NOT ``cu_done``: the user asked a QUESTION, so reporting a
+ # completed job would claim work he never ordered and bury the fact that
+ # his answer is missing (live 2026-08-20 19:32, "Erledigt." spoken over a
+ # finished web search). Names the cause and offers the one way forward.
+ "lookup_unspoken": {
+ "de": ( # i18n-allow
+ "Ich habe die Infos, konnte sie aber gerade nicht vorlesen. "
+ "Soll ich es nochmal versuchen?"
+ ),
+ "en": (
+ "I have the information but couldn't read it out just now. "
+ "Want me to try again?"
+ ),
+ "es": ( # i18n-allow
+ "Tengo la información, pero no pude leerla en voz alta. "
+ "¿Lo intento otra vez?"
+ ),
+ },
+ # The lookup ran and came back empty. The honest answer to a question with
+ # no hit — never ``cu_done``, which would report a finished job instead.
+ "lookup_empty": {
+ "de": "Dazu habe ich nichts gefunden.", # i18n-allow
+ "en": "I didn't find anything on that.",
+ "es": "No encontré nada sobre eso.", # i18n-allow
+ },
# Success WITH the verifier's on-screen observation forwarded (the SUCCESS
# sibling of cu_failed_reason). Lets an informational request actually be
# answered — "open the browser and check my tabs" reads back the observed
diff --git a/tests/unit/realtime/test_gemini_live.py b/tests/unit/realtime/test_gemini_live.py
index a82144126a..ec94fcd828 100644
--- a/tests/unit/realtime/test_gemini_live.py
+++ b/tests/unit/realtime/test_gemini_live.py
@@ -900,6 +900,139 @@ async def test_tool_call_suppresses_intermediate_turn_complete() -> None:
assert receive_calls == 3
+async def test_tool_call_suppresses_turn_complete_from_a_later_message() -> None:
+ """The live wire splits the tool call and its boundary across messages.
+
+ The sibling test above packs both into ONE message, which is the only
+ shape the per-message check ever caught — so the suppression looked
+ covered while never firing against a real server. Vertex/Gemini Live sends
+ ``toolCall`` first and ``turnComplete`` in a message of its own moments
+ later (live 2026-08-20 19:32:41.399: 39 boundaries emitted, 0 withheld).
+ The session took each of those for a mute provider and spoke "Erledigt."
+ over the user's question while the real answer was thrown away.
+ """
+ sdk_turns = [
+ [
+ _fake_message(
+ tool_call=SimpleNamespace(
+ function_calls=[
+ SimpleNamespace(id="call-1", name="search_web", args={})
+ ]
+ )
+ ),
+ _fake_message(
+ server_content=SimpleNamespace(
+ output_transcription=None,
+ input_transcription=None,
+ interrupted=False,
+ turn_complete=True,
+ )
+ ),
+ ],
+ [
+ # The generation that carries the spoken answer, once the tool
+ # result has travelled. THIS boundary is the turn's real end.
+ _fake_message(
+ server_content=SimpleNamespace(
+ output_transcription=SimpleNamespace(text="Aqua Security …"),
+ input_transcription=None,
+ interrupted=False,
+ turn_complete=True,
+ )
+ )
+ ],
+ ]
+ receive_calls = 0
+
+ async def fake_receive():
+ nonlocal receive_calls
+ receive_calls += 1
+ turn_index = receive_calls - 1
+ if turn_index < len(sdk_turns):
+ for message in sdk_turns[turn_index]:
+ yield message
+
+ session = _GeminiLiveSession(
+ session=SimpleNamespace(receive=fake_receive),
+ connection_cm=SimpleNamespace(),
+ client=SimpleNamespace(),
+ session_id="split-tool-turn",
+ )
+
+ events = [event async for event in session.receive()]
+
+ assert [event.type for event in events] == [
+ "tool_call",
+ "output_transcript_delta",
+ "turn_complete",
+ ]
+
+
+async def test_a_real_mute_after_a_tool_still_reaches_the_session() -> None:
+ """Suppression covers the tool-call boundary only, never a genuine mute.
+
+ The counterweight to the two tests above. What the session does with an
+ empty boundary — retry the speech from the retained tool result, and
+ failing that speak it itself — is the recovery for a model that takes a
+ tool result and says nothing. Withholding THAT boundary too would trade a
+ wrong answer for a twenty-second silence (the turn-stall watchdog), so the
+ generation AFTER the tool result must still close the turn when it produced
+ nothing at all.
+ """
+ sdk_turns = [
+ [
+ _fake_message(
+ tool_call=SimpleNamespace(
+ function_calls=[
+ SimpleNamespace(id="call-1", name="search_web", args={})
+ ]
+ )
+ ),
+ _fake_message(
+ server_content=SimpleNamespace(
+ output_transcription=None,
+ input_transcription=None,
+ interrupted=False,
+ turn_complete=True,
+ )
+ ),
+ ],
+ [
+ # The tool result travelled and the model produced NOTHING.
+ _fake_message(
+ server_content=SimpleNamespace(
+ output_transcription=None,
+ input_transcription=None,
+ interrupted=False,
+ turn_complete=True,
+ )
+ )
+ ],
+ ]
+ receive_calls = 0
+
+ async def fake_receive():
+ nonlocal receive_calls
+ receive_calls += 1
+ turn_index = receive_calls - 1
+ if turn_index < len(sdk_turns):
+ for message in sdk_turns[turn_index]:
+ yield message
+
+ session = _GeminiLiveSession(
+ session=SimpleNamespace(receive=fake_receive),
+ connection_cm=SimpleNamespace(),
+ client=SimpleNamespace(),
+ session_id="mute-after-tool",
+ )
+
+ events = [event async for event in session.receive()]
+
+ assert [event.type for event in events] == ["tool_call", "turn_complete"]
+
+
# --- BUG-088: conversation-history seeding into a fresh session -------------
diff --git a/tests/unit/realtime/test_lookup_never_reports_done.py b/tests/unit/realtime/test_lookup_never_reports_done.py
new file mode 100644
index 0000000000..5834e6065a
--- /dev/null
+++ b/tests/unit/realtime/test_lookup_never_reports_done.py
@@ -0,0 +1,254 @@
+"""A finished LOOKUP is never reported to the user as a finished JOB.
+
+Live forensic 2026-08-20 19:32:41 (session 6a82cdf9, vertex-live). The
+maintainer asked a question about Y Combinator. ``search_web`` ran, succeeded
+and came back with hits. The live model then closed its generation without
+speaking — the ordinary Gemini tool-call boundary — and the session's
+direct-tool recovery built its spoken line, found no ``spoken_reply`` on the
+search result, and fell through to ``cu_done``: **"Erledigt."**
+
+Two lies in nine characters. Nothing was "erledigt": the maintainer never gave
+a task, he asked a question. And the answer he did ask for was sitting in the
+payload, unspoken, while the model's own rendering of it arrived two seconds
+later and was withheld as a duplicate.
+
+Contract:
+
+* A tool that ACTED and reported no words keeps ``cu_done`` — that is what the
+ phrase is for, and a lookup-shaped NAME on a contentless receipt does not
+ change that (``gmail`` sends mail as well as listing it).
+* A lookup that came back with CONTENT owes the user that content: the facts go
+ to the honesty-bound composer, and the floor under it says why the answer is
+ missing — never that something was completed.
+* A lookup that came back EMPTY says so. "I found nothing" is the honest answer
+ to a question; "Erledigt." reports a job.
+"""
+
+from __future__ import annotations
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.realtime.session import RealtimeVoiceSession, _lookup_facts
+from jarvis.voice.action_phrases import action_phrase
+
+SEARCH_HITS = [
+ {
+ "title": "Aqua Security",
+ "snippet": "Cloud native security company founded in 2015.",
+ "url": "https://example.invalid/aqua",
+ },
+ {
+ "title": "Y Combinator",
+ "snippet": "Startup accelerator based in California.",
+ "url": "https://example.invalid/yc",
+ },
+]
+
+
+class FakeTransport:
+ creates_responses_automatically = False
+
+ async def send_text(self, text):
+ del text
+
+ async def send_tool_result(self, call_id, name, result):
+ del call_id, name, result
+
+ async def request_response(self, *, required_tool=None):
+ del required_tool
+
+ async def interrupt(self):
+ pass
+
+ async def close(self):
+ pass
+
+
+class FakeProvider:
+ name = "fake"
+ supports_realtime = True
+ input_sample_rate = 16000
+ output_sample_rate = 24000
+
+ async def can_open_duplex_session(self):
+ return True
+
+ async def open_session(self, cfg):
+ del cfg
+ return FakeTransport()
+
+
+class AnsweringComposer:
+ """A live composer that rephrases the facts it was handed."""
+
+ def __init__(self, answer: str):
+ self.answer = answer
+ self.calls: list[dict] = []
+
+ async def compose(self, **kwargs):
+ self.calls.append(kwargs)
+ return self.answer
+
+
+def _cfg():
+ return SimpleNamespace(
+ brain=SimpleNamespace(reply_language="auto", providers={}),
+ stt=SimpleNamespace(language="auto"),
+ voice=SimpleNamespace(mode="realtime"),
+ latency=SimpleNamespace(enabled=False),
+ )
+
+
+def _build(composer=None):
+ brain = SimpleNamespace(_readback_composer=composer) if composer else None
+ sess = RealtimeVoiceSession(
+ session_id="lookup-done",
+ send_binary=lambda _data: asyncio.sleep(0),
+ send_json=lambda _message: asyncio.sleep(0),
+ provider=FakeProvider(),
+ config=_cfg(),
+ bus=None,
+ brain=brain,
+ )
+ sess._session = FakeTransport()
+ return sess
+
+
+def _search_result(rows):
+ return {
+ "success": True,
+ "output": {
+ "query": "Aqua Security Y Combinator",
+ "results": rows,
+ "backend": "duckduckgo",
+ "status": "ok",
+ **({"answer_instruction": "Answer from these hits."} if rows else {}),
+ },
+ }
+
+
+# ---------------------------------------------------------------------------
+# The regression itself
+# ---------------------------------------------------------------------------
+
+
+async def test_a_finished_search_is_never_spoken_as_erledigt() -> None:
+ sess = _build()
+ sess._direct_tool_results.append(("search_web", _search_result(SEARCH_HITS)))
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text != action_phrase("cu_done", sess._language)
+ assert text == action_phrase("lookup_unspoken", sess._language)
+
+
+async def test_the_retrieved_answer_is_spoken_when_a_composer_is_live() -> None:
+ composer = AnsweringComposer("Aqua Security is a cloud native security firm.")
+ sess = _build(composer)
+ sess._direct_tool_results.append(("search_web", _search_result(SEARCH_HITS)))
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text == "Aqua Security is a cloud native security firm."
+ # The composer may only rephrase what the tool returned.
+ assert composer.calls[0]["honesty_bound"] is True
+ retrieved = composer.calls[0]["facts"]["retrieved"]
+ assert any("Aqua Security" in item for item in retrieved)
+
+
+async def test_an_empty_search_says_so_instead_of_reporting_a_job_done() -> None:
+ sess = _build()
+ sess._direct_tool_results.append(("search_web", _search_result([])))
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text == action_phrase("lookup_empty", sess._language)
+
+
+# ---------------------------------------------------------------------------
+# What must NOT change: an action that ran still reports "done"
+# ---------------------------------------------------------------------------
+
+
+async def test_a_wordless_action_still_reports_done() -> None:
+ sess = _build()
+ sess._direct_tool_results.append(("open_app", {"success": True, "output": {}}))
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text == action_phrase("cu_done", sess._language)
+
+
+async def test_a_lookup_shaped_name_on_a_bare_receipt_still_reports_done() -> None:
+ """``gmail`` sends mail as well as listing it — the payload decides."""
+ sess = _build()
+ sess._direct_tool_results.append(("gmail", {"success": True, "output": {}}))
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text == action_phrase("cu_done", sess._language)
+
+
+async def test_a_turn_that_also_acted_still_owes_the_answer() -> None:
+ sess = _build()
+ sess._direct_tool_results.append(("open_app", {"success": True, "output": {}}))
+ sess._direct_tool_results.append(("search_web", _search_result(SEARCH_HITS)))
+
+ text, _succeeded = await sess._direct_tool_fallback_text()
+
+ assert text != action_phrase("cu_done", sess._language)
+
+
+# ---------------------------------------------------------------------------
+# _lookup_facts — the ground truth handed to the composer
+# ---------------------------------------------------------------------------
+
+
+def test_facts_carry_the_content_and_never_the_urls() -> None:
+ facts = _lookup_facts([("search_web", _search_result(SEARCH_HITS))])
+
+ joined = " ".join(facts["retrieved"])
+ assert "Cloud native security company" in joined
+ assert "example.invalid" not in joined
+
+
+def test_an_unknown_payload_shape_yields_no_facts() -> None:
+ """A raw ``str(dict)`` dump is exactly what the output filter exists to stop."""
+ facts = _lookup_facts([
+ ("mcp_thing", {"success": True, "output": {"rows": [{"a": 1}]}}),
+ ])
+
+ assert facts == {}
+
+
+def test_a_plain_string_payload_is_read() -> None:
+ facts = _lookup_facts([
+ ("wiki_read", {"success": True, "output": "The meeting is on Tuesday."}),
+ ])
+
+ assert facts == {"retrieved": ["The meeting is on Tuesday."]}
+
+
+def test_the_fact_list_is_bounded() -> None:
+ rows = [
+ {"title": f"Hit {index}", "snippet": "x" * 900, "url": ""}
+ for index in range(20)
+ ]
+ facts = _lookup_facts([("search_web", _search_result(rows))])
+
+ assert len(facts["retrieved"]) <= 5
+ assert all(len(item) <= 320 for item in facts["retrieved"])