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 loaded skill is not a finished deed — never report it as done

rubenluetke10-beepb99aa3c99a2d
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 0d51dc72be..6b1733db0c 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -11515,3 +11515,72 @@ TRANSPARENT — expose the wrapped object's whole surface, not the subset one
call site uses today — and any "optional capability" probe in the code
base (`getattr(x, "Method", None)`) is a place where a wrapper can lie
silently. When such a probe selects a weaker path, that path logs.
+
+## BUG-164: "Ich habe dir Musik angemacht" — nothing played; a skill-instruction load was reported as the finished deed (HIGH, FIXED 2026-08-22) <!-- i18n-allow: quoted live German utterance under forensic analysis -->
+
+**Symptom (maintainer, reported 2026-08-22).** In a live call (gemini-live,
+hybrid tool mode) the maintainer asked for some relaxed music. Jarvis answered
+"Alles klar! Ich habe dir entspannte Musik angemacht" — and no music played.
+Nothing had been started; the assistant reported a deed that never happened.
+
+**Forensic (``data/sessions.db`` ``voice_events`` + ``jarvis_desktop.log``,
+session c845a2ce, turn 1, 18:16:21–31).**
+
+* 18:16:21.942 the live model called ``run_skill`` for ``plugin-spotify``. The
+ tool succeeded in 19 ms and returned the skill's INSTRUCTIONS ("use the
+ connected Spotify … pass what the user said as query … say what actually
+ started") plus the directive "follow these now, using your available tools".
+ ``spotify`` itself was not declared natively (dropped under the declaration
+ budget; reachable only through ``jarvis_action``).
+* 18:16:21.983 Gemini Live emitted *interrupted* and *turn complete* 0.02 s
+ after the tool response — no audio, no transcript, no further function call.
+* 18:16:21.985 ``_recover_empty_provider_turn`` found one SUCCESSFUL direct
+ tool result, judged nothing unfinished, and sent the "just say it" prompt:
+ *the function call already finished … use only the function result … do not
+ call any function and do not repeat the action*.
+* 18:16:25 the model obeyed with a how-to as its "result": "Ich habe dir
+ entspannte Musik angemacht." The turn's only tool call remained ``run-skill``.
+
+**Cause.** A ``run-skill`` success is a RECEIPT FOR A TO-DO LIST, not for work:
+the tool has rendered instructions the model must still carry out with other
+tools. Every reader of ``_direct_tool_results`` treated it as a completed
+action: ``_turn_has_unfinished_work`` saw ``success=True`` and said nothing was
+owed, the continuation prompt therefore ordered a completion report and
+FORBADE the very call that would have done the job, and the deterministic
+fallback line (``_wordless_success_line``) would have spoken "Erledigt." for
+the same receipt. The model's sentence was the predictable product of that
+prompt, not a free invention. No "Tool Model" was involved: in hybrid mode the
+live model holds the functions and this turn never reached the delegate.
+
+**Fix (2026-08-22).** ``_is_skill_handoff_result`` recognises a ``run-skill``
+instruction load (``instructions`` + ``directive`` in the output; a resource
+read stays a real answer). ``_turn_has_pending_skill_handoff`` is true when
+such a load is the NEWEST result of the turn — loaded and not carried out.
+``_recover_empty_provider_turn`` then sends a third prompt variant
+(``_direct_tool_result_retry_prompt(pending_instructions=True)``): the turn is
+NOT over, carry the instructions out now (a tool without a native function is
+reached through ``jarvis_action``), never say something was played/sent/done
+unless a function result in this turn says so, and name plainly what could not
+run. ``_direct_tool_fallback_text`` speaks the new
+``skill_loaded_not_run`` phrase for a pending load ("Ich habe die Anleitung
+dafür geladen, aber noch nichts ausgeführt.") and otherwise drops hand-off <!-- i18n-allow: quoted product line -->
+receipts from the report, so they neither speak nor earn "Erledigt.". The
+``run-skill`` inline directive and the BrainManager's inline injection carry
+the same honesty clause for every brain. Tests:
+``tests/unit/realtime/test_skill_handoff_is_not_done.py`` (the 18:16 turn end
+to end, the classifier, pending vs. followed-up loads, every language).
+
+**Follow-up (not in this fix).** The declaration budget dropped ``spotify``,
+``gmail``, ``google_calendar``, ``home_assistant``, ``youtube_music`` and
+``spawn_worker`` from the native set on this box once the Linear/GitHub/
+NotebookLM MCP servers came online (169 over-budget names at 17:10, 28 at
+16:50) — ADR-0035 §4 drops "everything else, biggest first" after the MCP/CLI/
+Agentic-IDE families. First-party plugin tools behind an installed skill
+deserve a higher rank than a generic bucket; that is a T2 change to
+``_BUDGET_DROP_FAMILIES``.
+
+**Lesson (BUG-160 family).** A tool result's ``success`` flag says the TOOL
+ran, not that the USER'S REQUEST happened. Any tool whose output is
+instructions for the model (``run-skill``, ``answer_instruction`` lookups,
+mission directives) is a hand-off, and every reader that turns results into a
+completion claim — prompts and canned lines alike — must classify it as such.
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index e7124c1b6f..c102b4cd29 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -6112,7 +6112,9 @@ class BrainManager:
"Follow these skill instructions now, step by step, using your "
"available tools; skip a step gracefully when its integration is "
"unavailable. Answer the user with the RESULT — never read the "
- "instructions aloud."
+ "instructions aloud. Report a step as done only after the tool "
+ "call that performs it has returned a successful result; if a "
+ "step cannot run, say plainly that it did not happen."
)
def _publish_skill_invoked(self, skill_name: str, *, source: str) -> None:
diff --git a/jarvis/plugins/tool/run_skill.py b/jarvis/plugins/tool/run_skill.py
index 4c7b9b90ed..b12fd92c78 100644
--- a/jarvis/plugins/tool/run_skill.py
+++ b/jarvis/plugins/tool/run_skill.py
@@ -56,7 +56,10 @@ _INLINE_DIRECTIVE = (
"These are the skill's instructions. Follow these skill instructions now, "
"step by step, using your available tools. Skip a step gracefully when its "
"integration is unavailable. Then answer the user with the result — never "
- "read the raw instructions aloud."
+ "read the raw instructions aloud. Loading these instructions has done "
+ "nothing for the user yet: report a step as done only after the tool call "
+ "that performs it has returned a successful result, and if a step cannot "
+ "run, say plainly that it did not happen."
)
_MISSION_DIRECTIVE = (
"This skill runs as a background mission. Call the spawn_worker tool NOW "
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index cfa8f132d5..fcb9da2aae 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -1413,8 +1413,38 @@ def _reported_empty_results(
return False
+def _is_skill_handoff_result(name: str, result: dict[str, Any]) -> bool:
+ """True when ``result`` is a ``run-skill`` load: instructions, not work.
+
+ ``run-skill`` succeeds the moment it has RENDERED a skill body for the
+ model to follow with its other tools (``jarvis/plugins/tool/run_skill.py``:
+ the output carries ``instructions`` plus a ``directive`` saying "follow
+ these now"). Nothing the user asked for has happened at that point — the
+ tool that does the work has not even been called. Live forensic 2026-08-22
+ 18:16:21 (session c845a2ce, gemini-live, "mach mal Musik an"): the live
+ model called ``run-skill`` for ``plugin-spotify``, Gemini Live closed the
+ turn 0.02 s after the tool response with no output, and the recovery — which
+ read the successful ``run-skill`` receipt as a finished action — told the
+ model "the function call already finished, speak the result, do not call
+ any function". The model obliged: "Ich habe dir entspannte Musik
+ angemacht." No Spotify call was ever made.
+
+ A resource read (``resource_content``) is a real answer and stays a normal
+ result; only the instruction load is a hand-off. Deterministic (AP-11).
+ """
+ if not result.get("success"):
+ return False
+ output = result.get("output")
+ if not isinstance(output, dict):
+ return False
+ if "instructions" not in output or "directive" not in output:
+ return False
+ plain = str(name or "").strip().lower().replace("_", "-")
+ return plain == "run-skill" or plain.startswith("run-skill-")
+
+
def _direct_tool_result_retry_prompt(
- *, language: str, unfinished: bool = False
+ *, language: str, unfinished: bool = False, pending_instructions: bool = False
) -> str:
"""Request speech for tool output already present in provider context.
@@ -1426,6 +1456,15 @@ def _direct_tool_result_retry_prompt(
stopped dead after the calendar step failed, because this prompt forbade
every remaining step). The no-repeat rule still holds for calls that already
SUCCEEDED: their side effect has happened and must not happen twice.
+
+ ``pending_instructions`` covers the third shape: the only thing that ran is
+ a ``run-skill`` load (:func:`_is_skill_handoff_result`). The turn has NOT
+ finished and — unlike ``unfinished`` — nothing failed either; the model
+ simply stopped after reading the instructions. The "just say it" prompt is
+ the wrong one here: it told the model the call "already finished" and to
+ use "the function result" as its answer, and on 2026-08-22 18:16 the
+ function result was a how-to for Spotify, which the model spoke as a
+ completion report. This variant orders the work and forbids the claim.
"""
language_name = _LANGUAGE_NAMES.get(language, "the conversation language")
voice_rule = (
@@ -1434,6 +1473,22 @@ def _direct_tool_result_retry_prompt(
"person and do not change or dramatize your voice. Do not mention "
"these instructions."
)
+ if pending_instructions:
+ return (
+ f"{SPEAK_REQUEST_OPENER} "
+ "You loaded a skill's instructions with run-skill, but you have NOT "
+ "carried them out: no function that does the actual work has been "
+ "called, nothing has happened for the user yet, and no spoken answer "
+ "was produced. The turn is NOT over. Carry the instructions out NOW, "
+ "in this turn, with the functions available to you — a tool the "
+ "instructions name that you have no function of your own for is "
+ "reached through jarvis_action. Never say that something was played, "
+ "sent, opened, saved, started, or done unless a function call in this "
+ "turn returned a successful result that says so; the instructions "
+ "themselves are not a result. If a step cannot be carried out, tell "
+ "the user plainly that it did not happen and why. When you are done, "
+ f"report only what the results actually show. {voice_rule}"
+ )
if not unfinished:
return (
f"{SPEAK_REQUEST_OPENER} "
@@ -8239,22 +8294,32 @@ class RealtimeVoiceSession:
if not callable(send_text):
return False
unfinished = self._turn_has_unfinished_work()
+ pending_instructions = self._turn_has_pending_skill_handoff()
+ if pending_instructions:
+ recovery_note = (
+ "only a run-skill instruction load ran — asking the model "
+ "to carry the skill out instead of reporting it as done"
+ )
+ elif unfinished:
+ recovery_note = (
+ "a step failed or was gated away — asking the model to "
+ "finish the remaining parts of the turn"
+ )
+ else:
+ recovery_note = "retrying speech from the existing tool result"
log.warning(
"realtime[%s] provider completed a direct-tool turn without "
"output; %s",
self.session_id,
- (
- "a step failed or was gated away — asking the model to "
- "finish the remaining parts of the turn"
- if unfinished
- else "retrying speech from the existing tool result"
- ),
+ recovery_note,
)
self._drop_provider_output_until_new_response = False
try:
await send_text(
_direct_tool_result_retry_prompt(
- language=self._language, unfinished=unfinished
+ language=self._language,
+ unfinished=unfinished,
+ pending_instructions=pending_instructions,
)
)
except Exception: # noqa: BLE001 -- local TTS fallback runs below
@@ -8490,6 +8555,24 @@ class RealtimeVoiceSession:
return True
return False
+ def _turn_has_pending_skill_handoff(self) -> bool:
+ """True when the turn's LAST result is a ``run-skill`` instruction load.
+
+ A skill load hands the model a to-do list; the work happens in the
+ calls that follow it. When no call follows — the load is the newest
+ result of the turn — the skill has been read and not carried out, and
+ the turn still owes the user the action (live 2026-08-22 18:16:21,
+ "mach mal Musik an": ``run-skill`` → ``plugin-spotify`` instructions →
+ no Spotify call → "Ich habe dir Musik angemacht"). A load followed by
+ any later call, successful or not, is no longer pending: the later
+ result is what the turn is then judged on. Deterministic, no LLM
+ (AP-11).
+ """
+ if not self._direct_tool_results:
+ return False
+ name, result = self._direct_tool_results[-1]
+ return _is_skill_handoff_result(name, result)
+
def _speakable_result_text(self, result: dict[str, Any]) -> str:
"""The voice-safe text a single tool result carries, or ``""``.
@@ -8673,8 +8756,21 @@ class RealtimeVoiceSession:
(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 = [pair for pair in results if not pair[1].get("blocked")]
+ # Rule 0: a ``run-skill`` load is a to-do list, not a deed. When it is
+ # the newest thing that ran, nothing the user asked for has happened —
+ # the line says so instead of "Erledigt." (live 2026-08-22 18:16: the
+ # receipt of a Spotify how-to was the turn's only success, and the
+ # stock completion line would have been the same lie the model told).
+ if self._turn_has_pending_skill_handoff():
+ return action_phrase("skill_loaded_not_run", self._language), False
+ # Rule 1: policy blocks carry model instructions, not user-facing text,
+ # and a skill load that WAS followed by real work is a receipt of
+ # nothing: it neither speaks nor counts as an action ("Erledigt.").
+ speakable = [
+ pair
+ for pair in results
+ if not pair[1].get("blocked") and not _is_skill_handoff_result(*pair)
+ ]
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
diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.py
index e7f664e7e4..6992fbca0e 100644
--- a/jarvis/voice/action_phrases.py
+++ b/jarvis/voice/action_phrases.py
@@ -338,6 +338,17 @@ _PHRASES: dict[str, dict[str, str]] = {
"en": "I didn't run anything for that. Tell me what you want done.",
"es": "No ejecuté nada para eso. Dime qué quieres que haga.",
},
+ # The only thing that ran was a ``run-skill`` instruction load: the model
+ # read HOW to do it and then stopped, the tool that does the work was never
+ # called. "Erledigt." here is a completion claim for nothing (live forensic
+ # 2026-08-22 18:16: "Ich habe dir entspannte Musik angemacht" — no Spotify
+ # call ever happened). The line says exactly what happened and what did
+ # not, so the user knows the ball is still in play.
+ "skill_loaded_not_run": {
+ "de": "Ich habe die Anleitung dafür geladen, aber noch nichts ausgeführt.", # i18n-allow
+ "en": "I loaded the instructions for that, but I haven't carried them out yet.",
+ "es": "Cargué las instrucciones para eso, pero todavía no las ejecuté.",
+ },
# A local action that ran past its short deadline. Replaces the old
# tool-name-prefixed "X timeout after 3s" machine string (which leaked the
# internal tool name) with a plain, honest sentence.
diff --git a/tests/unit/realtime/test_skill_handoff_is_not_done.py b/tests/unit/realtime/test_skill_handoff_is_not_done.py
new file mode 100644
index 0000000000..926cc0548c
--- /dev/null
+++ b/tests/unit/realtime/test_skill_handoff_is_not_done.py
@@ -0,0 +1,373 @@
+"""A ``run-skill`` load is a to-do list, not a deed — never report it as done.
+
+Live forensic 2026-08-22 18:16:21 (session c845a2ce, gemini-live, hybrid tool
+mode). The maintainer said "mach mal bitte schnell Musik an, entspannte".
+What happened, from ``voice_events`` and ``jarvis_desktop.log``:
+
+* 18:16:21.942 the live model called ``run_skill`` for ``plugin-spotify``; the
+ tool succeeded in 19 ms and returned the skill's INSTRUCTIONS ("use the
+ connected Spotify ... pass what the user said as query ... say what actually
+ started") with the directive "follow these now, using your available tools".
+* 18:16:21.985 Gemini Live closed the turn 0.02 s after the tool response —
+ no audio, no transcript, no further function call. The ``spotify`` tool was
+ never called (it was not even declared natively: dropped under the
+ declaration budget, reachable only through ``jarvis_action``).
+* 18:16:21.985 the empty-turn recovery found one SUCCESSFUL direct tool
+ result, judged the turn finished, and sent the "just say it" prompt: *"the
+ function call for the user's current request already finished ... use only
+ the function result ... do not call any function and do not repeat the
+ action"*.
+* 18:16:25 the model did exactly that with a how-to as its "result":
+ "Alles klar! Ich habe dir entspannte Musik angemacht." Nothing had played.
+
+Two defects, one symptom, both pinned here:
+
+1. The recovery treated a skill-instruction load as completed work, so its
+ continuation prompt ordered a completion report and forbade the very call
+ that would have done the work.
+2. The deterministic fallback line for such a turn would have been the stock
+ completion claim ("Erledigt.") — the same lie, spoken by us instead of the
+ model.
+"""
+
+from __future__ import annotations
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.realtime.session import (
+ RealtimeVoiceSession,
+ _direct_tool_result_retry_prompt,
+ _is_skill_handoff_result,
+)
+from jarvis.voice.action_phrases import action_phrase
+
+SPOTIFY_INSTRUCTIONS = (
+ "Use the connected Spotify to play and steer the user's music. Play by "
+ "name, not by id: pass what the user said as `query`. Say what actually "
+ "started."
+)
+INLINE_DIRECTIVE = (
+ "These are the skill's instructions. Follow these skill instructions now, "
+ "step by step, using your available tools."
+)
+
+
+class FakeTransport:
+ creates_responses_automatically = False
+
+ def __init__(self):
+ self.text_inputs = []
+
+ async def send_text(self, text):
+ self.text_inputs.append(text)
+
+ async def send_tool_result(self, call_id, name, result):
+ pass
+
+ 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()
+
+
+def _cfg():
+ return SimpleNamespace(
+ brain=SimpleNamespace(reply_language="auto", providers={}),
+ stt=SimpleNamespace(language="auto"),
+ voice=SimpleNamespace(mode="realtime"),
+ latency=SimpleNamespace(enabled=False),
+ )
+
+
+def _build():
+ jsons = []
+ sess = RealtimeVoiceSession(
+ session_id="skill-handoff",
+ send_binary=lambda _data: asyncio.sleep(0),
+ send_json=lambda message: jsons.append(message) or asyncio.sleep(0),
+ provider=FakeProvider(),
+ config=_cfg(),
+ bus=None,
+ brain=None,
+ )
+ sess._session = FakeTransport()
+ sess._language = "de"
+ return sess, jsons
+
+
+def _spotify_skill_load():
+ """The exact ``run-skill`` receipt of 18:16:21.962."""
+ return (
+ "run-skill",
+ {
+ "success": True,
+ "output": {
+ "skill_name": "plugin-spotify",
+ "execution": "inline",
+ "directive": INLINE_DIRECTIVE,
+ "instructions": SPOTIFY_INSTRUCTIONS,
+ "resources": {},
+ },
+ },
+ )
+
+
+def _spotify_played():
+ return (
+ "spotify",
+ {
+ "success": True,
+ "spoken_reply": "Playing Weightless by Marconi Union.",
+ },
+ )
+
+
+def _spotify_failed():
+ return (
+ "spotify",
+ {
+ "success": False,
+ "output": None,
+ "error": "Spotify is not connected — connect it in the Plugins view.",
+ },
+ )
+
+
+# ---------------------------------------------------------------------------
+# The classifier: what IS a hand-off
+# ---------------------------------------------------------------------------
+
+
+def test_a_run_skill_instruction_load_is_a_handoff() -> None:
+ assert _is_skill_handoff_result(*_spotify_skill_load()) is True
+
+
+def test_the_live_wire_spelling_is_recognised_too() -> None:
+ """Gemini/Vertex call the tool ``run_skill`` / ``run_skill_<digest>``."""
+ _name, result = _spotify_skill_load()
+ assert _is_skill_handoff_result("run_skill", result) is True
+ assert _is_skill_handoff_result("run_skill_982bc264fb", result) is True
+
+
+def test_a_resource_read_is_a_real_answer_not_a_handoff() -> None:
+ """L3: the model asked for a bundled file and got its content."""
+ result = {
+ "success": True,
+ "output": {
+ "skill_name": "plugin-spotify",
+ "resource": "references/guide.md",
+ "resource_content": "# Guide",
+ },
+ }
+ assert _is_skill_handoff_result("run-skill", result) is False
+
+
+def test_a_failed_skill_load_is_not_a_handoff() -> None:
+ result = {"success": False, "output": None, "error": "Unknown skill: x"}
+ assert _is_skill_handoff_result("run-skill", result) is False
+
+
+def test_another_tool_carrying_instructions_is_not_a_handoff() -> None:
+ _name, result = _spotify_skill_load()
+ assert _is_skill_handoff_result("spotify", result) is False
+
+
+# ---------------------------------------------------------------------------
+# Pending hand-off: loaded and not carried out
+# ---------------------------------------------------------------------------
+
+
+def test_a_load_with_nothing_after_it_is_pending() -> None:
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ assert sess._turn_has_pending_skill_handoff() is True
+
+
+def test_a_load_followed_by_the_real_call_is_not_pending() -> None:
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(_spotify_played())
+ assert sess._turn_has_pending_skill_handoff() is False
+
+
+def test_a_load_followed_by_a_failed_call_is_not_pending_but_unfinished() -> None:
+ """The later result is what the turn is judged on: failure → finish it."""
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(_spotify_failed())
+ assert sess._turn_has_pending_skill_handoff() is False
+ assert sess._turn_has_unfinished_work() is True
+
+
+def test_an_empty_turn_has_no_pending_handoff() -> None:
+ sess, _jsons = _build()
+ assert sess._turn_has_pending_skill_handoff() is False
+
+
+# ---------------------------------------------------------------------------
+# Defect 2 — the deterministic line never claims the deed
+# ---------------------------------------------------------------------------
+
+
+async def test_the_fallback_line_for_a_pending_load_says_nothing_ran() -> None:
+ """18:16 verbatim: one successful run-skill receipt and nothing else."""
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is False
+ assert text == action_phrase("skill_loaded_not_run", "de")
+ # The two lies this turn could have told — never again.
+ assert text != action_phrase("cu_done", "de")
+ assert "angemacht" not in text # i18n-allow: quoted live hallucination
+ # And the instructions themselves never leak into speech.
+ assert "query" not in text.lower()
+ assert "Spotify" not in text
+
+
+async def test_the_fallback_line_exists_in_every_supported_language() -> None:
+ for language in ("de", "en", "es"):
+ line = action_phrase("skill_loaded_not_run", language)
+ assert line
+ assert line != action_phrase("cu_done", language)
+
+
+async def test_a_load_followed_by_real_work_reports_the_work_only() -> None:
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(_spotify_played())
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is True
+ assert text == "Playing Weightless by Marconi Union."
+
+
+async def test_a_load_followed_by_a_failure_names_the_failure() -> None:
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(_spotify_failed())
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is False
+ assert "Spotify" in text
+ assert text != action_phrase("cu_done", "de")
+
+
+async def test_a_load_followed_only_by_a_gated_call_is_not_broken() -> None:
+ """Loaded, then the follow-up call was gated: nothing ran, nothing broke."""
+ sess, _jsons = _build()
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(
+ (
+ "spawn_worker",
+ {"success": False, "blocked": True, "output": None, "error": "gated"},
+ )
+ )
+
+ text, succeeded = await sess._direct_tool_fallback_text()
+
+ assert succeeded is False
+ assert text == action_phrase("actions_not_requested", "de")
+
+
+# ---------------------------------------------------------------------------
+# Defect 1 — the continuation prompt orders the work and forbids the claim
+# ---------------------------------------------------------------------------
+
+
+def test_the_pending_instructions_prompt_orders_the_work() -> None:
+ prompt = _direct_tool_result_retry_prompt(language="de", pending_instructions=True)
+ lowered = prompt.lower()
+
+ # The instruction that produced "Ich habe dir Musik angemacht" must be gone.
+ assert "already finished" not in lowered
+ assert "do not call any function" not in lowered
+ # ... and replaced by its opposite.
+ assert "not over" in lowered
+ assert "carry the instructions out now" in lowered
+ # The bridge to tools the live model has no function for.
+ assert "jarvis_action" in prompt
+ # The claim is forbidden in so many words.
+ assert "never say that something was played" in lowered
+ assert "instructions themselves are not a result" in lowered
+
+
+def test_the_pending_instructions_prompt_outranks_the_plain_readback() -> None:
+ """Both flags false → plain readback; pending set → the work order."""
+ plain = _direct_tool_result_retry_prompt(language="de")
+ pending = _direct_tool_result_retry_prompt(language="de", pending_instructions=True)
+ assert plain != pending
+ assert "do not call any function" in plain.lower()
+
+
+async def test_the_empty_turn_recovery_sends_the_work_order_for_a_pending_load() -> None:
+ """End to end through ``_recover_empty_provider_turn``: the 18:16 turn."""
+ sess, _jsons = _build()
+ transport = sess._session
+ sess._turn_id = "turn-1816"
+ sess._last_user_text = "Mach mal bitte schnell Musik an, entspannte." # i18n-allow
+ sess._direct_tool_results.append(_spotify_skill_load())
+
+ handled = await sess._recover_empty_provider_turn()
+
+ assert handled is True
+ assert len(transport.text_inputs) == 1
+ sent = transport.text_inputs[0].lower()
+ assert "not over" in sent
+ assert "already finished" not in sent
+ assert "do not call any function" not in sent
+ # The retained emergency line is the honest one, never a completion claim.
+ state = sess._delegate_turns["turn-1816"]
+ assert state.last_reply == action_phrase("skill_loaded_not_run", "de")
+ assert state.result_success is False
+
+
+async def test_the_empty_turn_recovery_keeps_the_plain_readback_for_real_work() -> None:
+ """Regression guard: a turn that DID the work still gets 'just say it'."""
+ sess, _jsons = _build()
+ transport = sess._session
+ sess._turn_id = "turn-ok"
+ sess._last_user_text = "Mach Musik an." # i18n-allow
+ sess._direct_tool_results.append(_spotify_skill_load())
+ sess._direct_tool_results.append(_spotify_played())
+
+ handled = await sess._recover_empty_provider_turn()
+
+ assert handled is True
+ sent = transport.text_inputs[0].lower()
+ assert "do not call any function" in sent
+ assert "already finished" in sent
+ state = sess._delegate_turns["turn-ok"]
+ assert state.last_reply == "Playing Weightless by Marconi Union."
+ assert state.result_success is True