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(music): reroute unnamed play calls to the connected service

Harald414ad533ba17
diff --git a/jarvis/brain/tool_use_loop.py b/jarvis/brain/tool_use_loop.py
index 63969ae984..6f719b65e3 100644
--- a/jarvis/brain/tool_use_loop.py
+++ b/jarvis/brain/tool_use_loop.py
@@ -666,6 +666,53 @@ class ToolUseLoop:
)
return tool, alias
+ def _reroute_music_tool(
+ self,
+ tool: Tool | None,
+ tool_name: str,
+ tool_args: Any,
+ user_utterance: str,
+ ) -> tuple[Tool | None, str, Any]:
+ """Send an unnamed music call to the preferred/only connected service.
+
+ Same resolver the skill capture uses. A named service still wins.
+ Never raises — a fault keeps the model's pick.
+ """
+ try:
+ from jarvis.core.music_constants import MUSIC_PLUGIN_IDS
+ from jarvis.core.music_service import (
+ adapt_music_arguments,
+ reroute_music_tool,
+ )
+ except Exception: # noqa: BLE001 — a routing nicety must never break a turn
+ return tool, tool_name, tool_args
+ if tool_name not in MUSIC_PLUGIN_IDS:
+ return tool, tool_name, tool_args
+ try:
+ target = reroute_music_tool(tool_name, user_utterance)
+ except Exception as exc: # noqa: BLE001
+ log.debug("tool_use_loop: music tool reroute skipped: %s", exc)
+ return tool, tool_name, tool_args
+ if target == tool_name:
+ return tool, tool_name, tool_args
+ new_tool, new_name = self._resolve_tool(target)
+ if new_tool is None:
+ return tool, tool_name, tool_args
+ log.info(
+ "tool_use_loop: music tool rerouted %s -> %s",
+ tool_name,
+ new_name,
+ )
+ args = tool_args if isinstance(tool_args, dict) else {}
+ try:
+ adapted = adapt_music_arguments(
+ user_utterance, source=tool_name, target=new_name, args=args
+ )
+ except Exception as exc: # noqa: BLE001
+ log.debug("tool_use_loop: music arg adapt skipped: %s", exc)
+ adapted = args
+ return new_tool, new_name, adapted
+
async def _publish_guard_denied(
self, tool_name: str, reason: str, tid: UUID,
) -> None:
@@ -912,6 +959,9 @@ class ToolUseLoop:
first_input = first_call.get("input", {}) or {}
if not isinstance(first_input, dict):
first_input = {}
+ _, first_name, first_input = self._reroute_music_tool(
+ None, first_name, first_input, user_utterance
+ )
try:
await ack_emitter(first_name, first_input)
except Exception as exc: # noqa: BLE001 — emitter must never block tool execution
@@ -962,6 +1012,9 @@ class ToolUseLoop:
# and the tool-result message all key on it); the raw model
# spelling stays in ``final_agg.tool_calls`` above.
tool, tool_name = self._resolve_tool(tool_name)
+ tool, tool_name, tool_args = self._reroute_music_tool(
+ tool, tool_name, tool_args, user_utterance
+ )
stt_blocked, stt_reason = (
_is_stt_hallucinated(tool_name, tool_args)
if tool is not None else (False, "")
diff --git a/jarvis/core/music_service.py b/jarvis/core/music_service.py
index 1c8709673e..ef0510c767 100644
--- a/jarvis/core/music_service.py
+++ b/jarvis/core/music_service.py
@@ -9,10 +9,12 @@ module is the one place that decides, pure and unit-testable:
3. Otherwise ``auto``: the only connected service, else the skill that matched
the turn (Spotify by catalog order — the behaviour before the setting).
-The brain applies the answer to the deterministic skill capture; the two
-music tools carry it in their descriptions so the LLM router makes the same
-choice on the turns no skill captures. Both read the SAME resolver, so a
-preference can never be honoured in one place and ignored in the other.
+The brain applies the answer to the deterministic skill capture. The two
+music tools put the same sentence at the START of their descriptions (hybrid
+live models compact to 450 characters, so a trailing hint was being cut).
+Execute-time reroute (``reroute_music_tool``) is the correctness boundary:
+prompt compliance is not one (hybrid live 2026-08-19: preference YouTube
+Music, Spotify not connected, the live model still called ``spotify``).
"""
from __future__ import annotations
@@ -42,6 +44,29 @@ _EXPLICIT: tuple[tuple[str, re.Pattern[str]], ...] = (
_LABELS = {MUSIC_SERVICE_SPOTIFY: "Spotify", MUSIC_SERVICE_YOUTUBE_MUSIC: "YouTube Music"}
+# "play something I like" is liked songs, not a title search.
+# Word-boundaried so a song title that happens to contain "like" stays a title.
+_TASTE_RE = re.compile(
+ r"(?:"
+ r"was\s+mir\s+gef[aä]llt|" # i18n-allow: spoken-input vocabulary
+ r"something\s+i\s+(?:like|love)|"
+ r"songs?\s+i\s+(?:like|love)|"
+ r"liked\s+songs?|"
+ r"meine\s+likes|" # i18n-allow: spoken-input vocabulary
+ r"lo\s+que\s+me\s+gusta"
+ r")",
+ re.IGNORECASE,
+)
+
+# Spotify `type=track` vs YouTube Music `type=song`.
+_TYPE_MAP: dict[tuple[str, str], dict[str, str]] = {
+ (MUSIC_SERVICE_SPOTIFY, MUSIC_SERVICE_YOUTUBE_MUSIC): {"track": "song"},
+ (MUSIC_SERVICE_YOUTUBE_MUSIC, MUSIC_SERVICE_SPOTIFY): {
+ "song": "track",
+ "liked": "playlist",
+ },
+}
+
log = logging.getLogger(__name__)
# Which music connectors hold a usable credential is a keyring read; the tool
@@ -180,9 +205,29 @@ def resolve_music_service(
def preference_hint(service_id: str, *, preferred: str, connected: Iterable[str]) -> str:
"""One sentence for a music tool's description, so the LLM router honours
- the same preference the skill capture does. Empty when there is nothing to
- say (one service, or no preference)."""
+ the same preference the skill capture does.
+
+ With only one service connected, the sentence names that service (and
+ tells the disconnected sibling not to take unnamed requests) — otherwise
+ a live model still sees both declarations and picks the disconnected
+ one. Empty only when nothing is connected, or two are connected with no
+ named preference (``auto``).
+ """
live = [pid for pid in MUSIC_PLUGIN_IDS if pid in set(connected)]
+ if len(live) == 1:
+ only = live[0]
+ if service_id == only:
+ return (
+ f" {service_label(only)} is the connected music service: use this tool "
+ "for any music request that does not name another service."
+ )
+ if service_id in MUSIC_PLUGIN_IDS:
+ return (
+ f" {service_label(service_id)} is not connected. Use "
+ f"{service_label(only)} for music unless the user names "
+ f"{service_label(service_id)} explicitly."
+ )
+ return ""
pref = (preferred or MUSIC_SERVICE_AUTO).strip().lower()
if len(live) < 2 or pref == MUSIC_SERVICE_AUTO or pref not in live:
return ""
@@ -197,13 +242,112 @@ def preference_hint(service_id: str, *, preferred: str, connected: Iterable[str]
)
+def compose_tool_description(service_id: str, base: str) -> str:
+ """Put the preference/connection sentence FIRST so a 450-character compact
+ live-model description still carries it."""
+ hint = description_hint(service_id).strip()
+ body = str(base or "").strip()
+ if not hint:
+ return body
+ return f"{hint} {body}" if body else hint
+
+
+def reroute_music_tool(called: str, text: str) -> str:
+ """The music tool this call should actually run (see module docstring).
+
+ ``called`` is the tool the model named. Unnamed requests go to the
+ preferred connected service, else the only connected one. A named
+ service still wins. Never raises — a fault keeps ``called``.
+ """
+ if called not in MUSIC_PLUGIN_IDS:
+ return called
+ try:
+ target = resolve_music_service(
+ text,
+ preferred=preferred_music_service(),
+ connected=connected_music_services(),
+ matched=called,
+ )
+ except Exception as exc: # noqa: BLE001 — a routing nicety must never break a turn
+ log.debug("music tool reroute skipped: %s", exc)
+ return called
+ return target if target in MUSIC_PLUGIN_IDS else called
+
+
+def adapt_music_arguments(
+ text: str,
+ *,
+ source: str,
+ target: str,
+ args: dict[str, object] | None,
+) -> dict[str, object]:
+ """Map arguments across the two music tools and, for a taste request
+ ("something I like"), play liked songs instead of searching the words
+ as a title."""
+ out: dict[str, object] = dict(args or {})
+ if source != target:
+ item_type = str(out.get("type") or "")
+ mapped = _TYPE_MAP.get((source, target), {}).get(item_type)
+ if mapped:
+ out["type"] = mapped
+ action = str(out.get("action") or "").strip()
+ if target == MUSIC_SERVICE_YOUTUBE_MUSIC and action in {
+ "list_devices",
+ "queue",
+ }:
+ out["action"] = "play"
+ elif target == MUSIC_SERVICE_SPOTIFY and action in {
+ "liked_songs",
+ "like",
+ "open",
+ "hide_player",
+ "add_to_playlist",
+ "create_playlist",
+ }:
+ if action in {"liked_songs", "like"}:
+ out["action"] = "play"
+ out["type"] = "playlist"
+ out.setdefault("query", "Liked Songs")
+ elif action in {"open", "hide_player"}:
+ out["action"] = "now_playing"
+ else:
+ out["action"] = "play"
+ return _apply_taste(text, target, out)
+
+
+def _apply_taste(
+ text: str, target: str, args: dict[str, object]
+) -> dict[str, object]:
+ if not _TASTE_RE.search(text or ""):
+ return args
+ action = str(args.get("action") or "play").strip() or "play"
+ if action not in {"play", "search", "now_playing"}:
+ return args
+ query = str(args.get("query") or "").strip()
+ if query and not _TASTE_RE.search(query):
+ # A concrete title in `query` still wins over the taste phrasing.
+ return args
+ args["action"] = "play"
+ if query:
+ args.pop("query", None)
+ if target == MUSIC_SERVICE_YOUTUBE_MUSIC:
+ args["type"] = "liked"
+ else:
+ args["type"] = "playlist"
+ args["query"] = "Liked Songs"
+ return args
+
+
__all__ = [
+ "adapt_music_arguments",
+ "compose_tool_description",
"connected_music_services",
"description_hint",
"explicit_music_service",
"forget_connected_music_services",
"preference_hint",
"preferred_music_service",
+ "reroute_music_tool",
"resolve_music_service",
"service_label",
]
diff --git a/jarvis/plugins/tool/spotify_rest.py b/jarvis/plugins/tool/spotify_rest.py
index 286fa12dd1..04a4b890c4 100644
--- a/jarvis/plugins/tool/spotify_rest.py
+++ b/jarvis/plugins/tool/spotify_rest.py
@@ -84,16 +84,6 @@ async def _default_refresher(observed_access_token: str | None = None) -> bool:
return attempt.usable
-def _preference_hint_for(service_id: str) -> str:
- """One sentence about ``[music] preferred_service`` for the tool
- description — cached in ``jarvis.core.music_service`` so a router turn
- never re-parses the config. Never raises (a description must not)."""
- try:
- from jarvis.core.music_service import description_hint
-
- return description_hint(service_id)
- except Exception: # noqa: BLE001 — a fault means no hint, not no tool
- return ""
def _artists(item: dict[str, Any]) -> str:
names = [a.get("name") for a in item.get("artists") or [] if a.get("name")]
return ", ".join(n for n in names if n)
@@ -168,8 +158,14 @@ class SpotifyRestTool:
def description(self) -> str:
"""The static description plus the user's music preference (see
``jarvis.core.music_service``): with YouTube Music also connected, the
- LLM router must send an unnamed music request where the setting says."""
- return self._BASE_DESCRIPTION + _preference_hint_for(self.name)
+ LLM router must send an unnamed music request where the setting says.
+ The hint is first so a compact live-model description still carries it."""
+ try:
+ from jarvis.core.music_service import compose_tool_description
+
+ return compose_tool_description(self.name, self._BASE_DESCRIPTION)
+ except Exception: # noqa: BLE001 — a description must not raise
+ return self._BASE_DESCRIPTION
schema: dict[str, Any] = {
"type": "object",
diff --git a/jarvis/plugins/tool/youtube_music_rest.py b/jarvis/plugins/tool/youtube_music_rest.py
index f223191b69..0703b570d3 100644
--- a/jarvis/plugins/tool/youtube_music_rest.py
+++ b/jarvis/plugins/tool/youtube_music_rest.py
@@ -165,16 +165,6 @@ def _default_playback_mode() -> str:
return str(load_config().music.playback)
-def _preference_hint_for(service_id: str) -> str:
- """One sentence about ``[music] preferred_service`` for the tool
- description — cached in ``jarvis.core.music_service`` so a router turn
- never re-parses the config. Never raises (a description must not)."""
- try:
- from jarvis.core.music_service import description_hint
-
- return description_hint(service_id)
- except Exception: # noqa: BLE001 — a fault means no hint, not no tool
- return ""
def _clean(text: Any) -> str:
return html.unescape(str(text or "")).strip()
@@ -267,9 +257,10 @@ class YouTubeMusicRestTool:
"one of their playlists or their liked songs (opens in YouTube Music in the "
"browser and keeps playing like a radio), pause, resume, skip, go back, say "
"what is playing right now, like a song, add a song to a playlist, create a "
- "playlist, list playlists. Use for 'play Radiohead on YouTube Music', "
- "'skip this', 'what song is this', 'pause the music', 'like this song', "
- "'add this to my running playlist'. Actions: now_playing, play, pause, "
+ "playlist, list playlists. Use for 'play Radiohead', 'play a nice song', "
+ "'play something I like', 'skip this', 'what song is this', "
+ "'pause the music', 'like this song', 'add this to my running playlist'. "
+ "Actions: now_playing, play, pause, "
"next, previous, search, list_playlists, playlist_tracks, liked_songs, "
"like, add_to_playlist, create_playlist, open (show the player), "
"hide_player, set_volume. Music plays in a background player window "
@@ -281,8 +272,14 @@ class YouTubeMusicRestTool:
def description(self) -> str:
"""The static description plus the user's music preference, so the
LLM router makes the same Spotify-vs-YouTube Music choice the skill
- capture does (one resolver, ``jarvis.core.music_service``)."""
- return self._BASE_DESCRIPTION + _preference_hint_for(self.name)
+ capture does (one resolver, ``jarvis.core.music_service``). The hint
+ is first so a compact live-model description still carries it."""
+ try:
+ from jarvis.core.music_service import compose_tool_description
+
+ return compose_tool_description(self.name, self._BASE_DESCRIPTION)
+ except Exception: # noqa: BLE001 — a description must not raise
+ return self._BASE_DESCRIPTION
schema: dict[str, Any] = {
"type": "object",
diff --git a/jarvis/skills/builtin/plugin-spotify/SKILL.md b/jarvis/skills/builtin/plugin-spotify/SKILL.md
index 8f50d8cb52..67c8e4d4bd 100644
--- a/jarvis/skills/builtin/plugin-spotify/SKILL.md
+++ b/jarvis/skills/builtin/plugin-spotify/SKILL.md
@@ -10,6 +10,12 @@ intent_objects: [spotify, musik, music, música, lied, song, canción, track, ti
triggers:
- type: voice
pattern: '(spotify|musik|music|música)' # i18n-allow: spoken-input vocabulary
+ # Play-verb + a music noun ("play a song" / "Lied abspielen") — the bare
+ # noun is not a trigger (a question about a song is not a play request).
+ # Generic capture lands here, then music_service swaps to the preferred
+ # connected connector.
+ - type: voice
+ pattern: '(spiel\w*|play|abspielen|pon|reproduce).{0,48}(lied|song|titel|track|playlist|album|canción)|(lied|song|titel|track|playlist|album|canción).{0,24}(spiel\w*|play|abspielen|pon|reproduce)' # i18n-allow: spoken-input vocabulary, de/en/es
requires_tools: [spotify]
risk_policy:
default_tier: monitor
diff --git a/tests/unit/core/test_music_service.py b/tests/unit/core/test_music_service.py
index 3b8dd2d364..2710f5c967 100644
--- a/tests/unit/core/test_music_service.py
+++ b/tests/unit/core/test_music_service.py
@@ -57,13 +57,66 @@ def test_auto_takes_the_only_connected_service_else_the_match():
def test_preference_hint_only_when_both_connected_and_a_preference_exists():
both = ("spotify", "youtube_music")
assert ms.preference_hint("spotify", preferred="auto", connected=both) == ""
- assert ms.preference_hint("spotify", preferred="youtube_music", connected=("spotify",)) == ""
+ only_spotify = ms.preference_hint(
+ "spotify", preferred="youtube_music", connected=("spotify",)
+ )
+ assert "connected music service" in only_spotify
pro = ms.preference_hint("youtube_music", preferred="youtube_music", connected=both)
con = ms.preference_hint("spotify", preferred="youtube_music", connected=both)
assert "prefers YouTube Music" in pro and "does not name another service" in pro
assert "prefers YouTube Music" in con and "names Spotify explicitly" in con
+def test_preference_hint_when_only_one_service_is_connected():
+ live = ("youtube_music",)
+ assert "connected music service" in ms.preference_hint(
+ "youtube_music", preferred="auto", connected=live
+ )
+ dead = ms.preference_hint("spotify", preferred="auto", connected=live)
+ assert "not connected" in dead and "YouTube Music" in dead
+
+
+def test_compose_tool_description_puts_the_hint_first(monkeypatch):
+ monkeypatch.setattr(ms, "description_hint", lambda _sid: " HINT.")
+ composed = ms.compose_tool_description("spotify", "Play songs.")
+ assert composed.startswith("HINT.") and composed.endswith("Play songs.")
+
+
+def test_reroute_music_tool_sends_unnamed_requests_to_the_preferred_service(
+ monkeypatch,
+):
+ monkeypatch.setattr(ms, "preferred_music_service", lambda: "youtube_music")
+ monkeypatch.setattr(
+ ms, "connected_music_services", lambda: ("spotify", "youtube_music")
+ )
+ unnamed = "Mach einfach irgendwie Schönes, was mir gefällt." # i18n-allow
+ assert ms.reroute_music_tool("spotify", unnamed) == "youtube_music"
+ named = "spiel das auf spotify" # i18n-allow: spoken-input sample
+ assert ms.reroute_music_tool("youtube_music", named) == "spotify"
+ assert ms.reroute_music_tool("search_web", unnamed) == "search_web"
+
+
+def test_reroute_music_tool_uses_the_only_connected_service(monkeypatch):
+ monkeypatch.setattr(ms, "preferred_music_service", lambda: "auto")
+ monkeypatch.setattr(ms, "connected_music_services", lambda: ("youtube_music",))
+ assert ms.reroute_music_tool("spotify", "play a nice song") == "youtube_music"
+
+
+def test_adapt_music_arguments_taste_request_plays_liked_songs():
+ text = "Mach einfach irgendwie Schönes, was mir gefällt." # i18n-allow
+ out = ms.adapt_music_arguments(
+ text, source="spotify", target="youtube_music", args={"action": "play"}
+ )
+ assert out["action"] == "play" and out["type"] == "liked"
+ titled = ms.adapt_music_arguments(
+ text,
+ source="spotify",
+ target="youtube_music",
+ args={"action": "play", "query": "Karma Police", "type": "track"},
+ )
+ assert titled["type"] == "song" and titled["query"] == "Karma Police"
+
+
def test_connected_music_services_reads_the_store_and_isolates_faults():
class Store:
def load(self, plugin_id):
diff --git a/tests/unit/realtime/test_hybrid_tool_mode.py b/tests/unit/realtime/test_hybrid_tool_mode.py
index 95a23d1cf7..8d3af2d718 100644
--- a/tests/unit/realtime/test_hybrid_tool_mode.py
+++ b/tests/unit/realtime/test_hybrid_tool_mode.py
@@ -370,6 +370,17 @@ def test_router_catalog_renders_for_every_realtime_wire() -> None:
# --- Execute-side turn-shape guards (live lesson 2026-08-19 12:50) ----------
[email protected](autouse=True)
+def _music_services_are_local(monkeypatch):
+ """Execute-time music reroute reads the token store; unit tests must not."""
+ monkeypatch.setattr(
+ "jarvis.core.music_service.connected_music_services", lambda: ()
+ )
+ monkeypatch.setattr(
+ "jarvis.core.music_service.preferred_music_service", lambda: "auto"
+ )
+
+
def _descriptor_with_tier(name: str, tier: str) -> SupervisorToolDescriptor:
return SupervisorToolDescriptor(
name=name,
@@ -384,12 +395,14 @@ class _RecordingGateway:
def __init__(self, descriptors):
self._items = tuple(descriptors)
self.executed: list[str] = []
+ self.arguments: list[object] = []
def catalog(self):
return self._items
- async def execute(self, name, _arguments, _request):
+ async def execute(self, name, arguments, _request):
self.executed.append(name)
+ self.arguments.append(arguments)
return ToolResult(success=True, output="ok")
async def publish_guard_denied(self, *_a, **_k):
@@ -462,6 +475,85 @@ async def test_monitor_tool_needs_an_order_a_tasking_or_a_world_request():
assert gateway.executed == ["google_calendar", "spotify", "search_web"]
+async def test_vertex_toolset_prefix_executes_the_declared_hybrid_tool():
+ """Live 2026-08-19 16:07: vertex-live called ``default:run_shell``.
+
+ The prefix is a transport artifact. Hybrid execute must still run the
+ declared tool instead of answering "not available in this session."
+ """
+ gateway, bridge = _guarded_bridge()
+ result = await _call(bridge, "default:search_web", "Was geht ab?") # i18n-allow
+ assert result["success"] is True
+ assert gateway.executed == ["search_web"]
+
+
+async def test_unnamed_music_call_is_rerouted_to_the_preferred_service(monkeypatch):
+ """Live 2026-08-19: preference YouTube Music, Spotify not connected, the
+ hybrid model still called ``spotify`` for an unnamed play-something-I-like
+ request. Execute-time reroute is the correctness boundary."""
+ from jarvis.core import music_service as ms
+
+ monkeypatch.setattr(ms, "preferred_music_service", lambda: "youtube_music")
+ monkeypatch.setattr(
+ ms, "connected_music_services", lambda: ("spotify", "youtube_music")
+ )
+ gateway = _RecordingGateway(
+ [
+ _descriptor_with_tier("spotify", "monitor"),
+ _descriptor_with_tier("youtube_music", "monitor"),
+ ]
+ )
+ bridge = RealtimeToolBridge(gateway=gateway, language="de", compact=True)
+ utterance = "Mach einfach irgendwie Schönes, was mir gefällt." # i18n-allow
+ result = await _call(bridge, "spotify", utterance)
+ assert result["success"] is True
+ assert gateway.executed == ["youtube_music"]
+ assert gateway.arguments and gateway.arguments[0].get("type") == "liked"
+
+
+async def test_named_music_service_is_not_rerouted(monkeypatch):
+ from jarvis.core import music_service as ms
+
+ monkeypatch.setattr(ms, "preferred_music_service", lambda: "youtube_music")
+ monkeypatch.setattr(
+ ms, "connected_music_services", lambda: ("spotify", "youtube_music")
+ )
+ gateway = _RecordingGateway(
+ [
+ _descriptor_with_tier("spotify", "monitor"),
+ _descriptor_with_tier("youtube_music", "monitor"),
+ ]
+ )
+ bridge = RealtimeToolBridge(gateway=gateway, language="de", compact=True)
+ named = "spiel das auf Spotify" # i18n-allow: spoken-input sample
+ result = await _call(bridge, "spotify", named)
+ assert result["success"] is True
+ assert gateway.executed == ["spotify"]
+
+
+async def test_disconnected_music_tool_reroutes_to_the_connected_sibling(
+ monkeypatch,
+):
+ from jarvis.core import music_service as ms
+
+ monkeypatch.setattr(ms, "preferred_music_service", lambda: "auto")
+ monkeypatch.setattr(ms, "connected_music_services", lambda: ("youtube_music",))
+ gateway = _RecordingGateway(
+ [
+ _descriptor_with_tier("spotify", "monitor"),
+ _descriptor_with_tier("youtube_music", "monitor"),
+ ]
+ )
+ bridge = RealtimeToolBridge(gateway=gateway, language="de", compact=True)
+ result = await _call(bridge, "spotify", "Spiel mir ein schönes Lied.") # i18n-allow
+ assert result["success"] is True
+ assert gateway.executed == ["youtube_music"]
+
+
def _wire_suffix(name: str) -> str:
import hashlib
diff --git a/tests/unit/skills/test_builtin_skills.py b/tests/unit/skills/test_builtin_skills.py
index 2b8f0a9673..3a7ab55c1c 100644
--- a/tests/unit/skills/test_builtin_skills.py
+++ b/tests/unit/skills/test_builtin_skills.py
@@ -206,3 +206,25 @@ def test_memory_save_specifics() -> None:
"memory-save must have no triggers — TriggerMatcher must not fire it"
)
assert fm.risk_policy.default_tier == "safe"
+
+
+def test_spotify_play_verb_plus_song_noun_triggers() -> None:
+ """Generic "play a song" must capture so music_service can swap to the
+ preferred connected connector. Live 2026-08-19: a play request that named
+ no service was taken by disconnected Spotify."""
+ skill = parse_skill(builtin_skill_path("plugin-spotify"))
+ assert skill.frontmatter is not None
+ patterns = [
+ re.compile(t.pattern, re.IGNORECASE)
+ for t in skill.frontmatter.triggers
+ if t.type == "voice" and t.pattern
+ ]
+ hits = "bitte mal ein schönes Lied abspielen?" # i18n-allow: live utterance
+ misses = "was bedeutet das Lied" # i18n-allow: definitional, no play verb
+ assert any(p.search(hits) for p in patterns)
+ # The brand/musik trigger still fires on "Lied" only if a play verb is
+ # next to it; a bare song-noun question must not.
+ play_noun = [
+ p for p in patterns if "lied" in (p.pattern or "") and "spotify" not in (p.pattern or "")
+ ]
+ assert play_noun and not any(p.search(misses) for p in play_noun)