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(brain): stop a config gate from swallowing a turn that briefs an agent

Ruben Lütke2cc074379dde
diff --git a/docs/BUGS.md b/docs/BUGS.md
index c811d39806..a6383af4d6 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -8289,3 +8289,74 @@ its subject's lifetime past the point where anything wants it — and when the
retry's side effect is spawning a process or a window, the leak becomes
user-visible on a machine nobody is testing on. Hold the subject weakly and
treat collection as cancellation.
+
+## BUG-120: a spoken order to brief two coding agents changes a SETTING instead — no prompt, no thought, and a confident report that both are working (HIGH, FIXED 2026-07-29)
+
+**Symptom (maintainer field report, voice session 2026-07-28 20:34).** Coding
+mode on, six panes open. The user asked, in one long dictated paragraph, for
+two named panes to be given split work. Jarvis answered "Alles klar, ich hab <!-- i18n-allow: verbatim quote of the runtime output under investigation -->
+T1 und T5 die Aufgaben gegeben …" ("sure, I gave T1 and T5 their tasks") and <!-- i18n-allow: verbatim quote of the runtime output under investigation -->
+named what each would do. Nothing had been written to either pane. No agent was briefed, and — the part that made
+this feel different from a delivery failure — nothing had even tried: no
+composer call, no fan-out, no brain turn.
+
+**Root cause (measured from the flight recorder, not inferred).** The turn was
+routed correctly (`path=orchestrator`, `reasons=…,workspace`) and the
+addressed-terminal detector was innocent: replayed against the verbatim
+transcript, `agentic_ide.intent.detect_all` returns T1 **and** T5,
+`kind='prompt'`. What killed it sits earlier. `BrainManager.generate` runs the
+deterministic self-configuration gates BEFORE the Agentic-IDE delivery path,
+and `voice_command_gate._match_language_switch` searched the WHOLE utterance
+for each ingredient of a language command *independently, with no proximity
+requirement*:
+
+| ingredient | matched | offset | what the user actually meant |
+|---|---|---|---|
+| language alias | the word for "automatically" | 458 | describing a bug — text is NOT inserted automatically |
+| `_LANG_OUTPUT_VERB` | the verb in "ask questions" | 866 | the panes should ASK if unsure |
+| `_LANG_PREP` | "in" | 398 | "in the text field" |
+
+Three unrelated clauses, up to 468 characters apart, assembled into "switch the
+reply language to auto". The gate applied it, persisted it to `jarvis.toml` and
+returned — 283 lines above `_run_agentic_ide_fast_path`. Timing confirms it end
+to end: `realtime_delegate_completed … success=True` after **519 ms**, where a
+real delivery needs 10-21 s for the prompt composer alone. A turn reported as
+successful that had done nothing but change a setting nobody asked about.
+
+The spoken confirmation was then handed to the live model, which re-renders
+injected text in its own words — so instead of "language set to automatic" the
+user heard a detailed account of a fleet briefing that never happened.
+
+**Fix (two layers, because either alone leaves the class open).**
+
+1. `_match_language_switch` binds its ingredients to a **window** around the
+ language word (`_command_window`: 60 characters, and never across a sentence
+ boundary). Scattered co-occurrence can no longer form a command. The
+ earliest QUALIFYING language still wins, so the 2026-06-27 first-language
+ rule is untouched; a language word with no command around it is skipped
+ instead of deciding the turn. `_language_words` also switched to `finditer`,
+ so a language named twice is judged at each place it appears.
+2. A turn that NAMES A RUNNING PANE outranks the self-configuration gates
+ altogether (`ide_owns_turn` in `generate`), the same precedence the desktop
+ gate already honours further down. Briefing an agent and changing a setting
+ are not things a user can mean at the same time. Deliberately NOT applied to
+ the cancel intercept: stopping work is a safety control and must keep
+ working under every phrasing.
+
+**Guards.** `tests/unit/brain/test_config_gate_vs_agentic_ide_routing.py` — the
+trimmed live transcript no longer reads as a language switch, both addressed
+panes are briefed end to end through `generate`, and a plain "switch to
+English" still works with six panes open. The precedence is proven
+independently of fix 1 by FORCING the detector to claim a language switch and
+asserting it is still overruled. `tests/unit/brain/test_voice_command_gate.py`
+adds the clause-proximity case. Verified sharp both ways: the trimmed
+transcript resolves to `auto` under the pre-fix matcher, and the forced-match
+test fails with the precedence removed.
+
+**Class rule.** A deterministic gate that assembles an intent from ingredients
+found ANYWHERE in the utterance will eventually assemble one out of a long
+dictated paragraph — the longer users talk, the likelier it is, so this gets
+worse exactly as voice input gets more natural. Bind every ingredient to a
+window around the anchor word. And when two deterministic gates can both claim
+a turn, the one holding the MORE SPECIFIC evidence must win: a named running
+agent beats a keyword match, however plausible the keyword looked.
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index 5ac258b6e6..18d18503bd 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -8936,7 +8936,32 @@ class BrainManager:
)
return confirmation
- switch_target = self._detect_switch_intent(user_text)
+ # An addressed Agentic-IDE pane outranks every self-configuration gate
+ # below — the same precedence the desktop gate already honours further
+ # down (``_agentic_ide_owns_turn`` there), applied here because the
+ # config gates run FIRST and therefore get the only chance to be wrong.
+ #
+ # Live 2026-07-28 20:34, coding mode on, six panes open: a spoken
+ # order to brief two of them was claimed by the reply-language gate on
+ # three unrelated words scattered across the utterance. It applied the
+ # setting and returned, so ``_run_agentic_ide_fast_path`` below never
+ # ran and no agent was briefed — while the live model, which is told
+ # none of this, reported both as working. The gate's own proximity
+ # bound (``voice_command_gate._match_language_switch``) is the first
+ # fix; this is the second, because a config gate winning a turn that
+ # NAMES A RUNNING AGENT is wrong however plausible its match looked —
+ # briefing an agent and changing a setting are not things a user can
+ # mean at the same time.
+ #
+ # Deliberately NOT applied to the cancel intercept above: stopping work
+ # is a safety control and must keep working under every phrasing.
+ # Cheap enough for the hot path — an in-memory regex sweep, no IO and
+ # no model call (AP-9/AP-11) — and it answers "no" on any fault.
+ ide_owns_turn = self._agentic_ide_owns_turn(user_text)
+
+ switch_target = (
+ None if ide_owns_turn else self._detect_switch_intent(user_text)
+ )
if switch_target:
confirmation = await self._apply_main_provider_switch(switch_target)
if confirmation:
@@ -8952,7 +8977,9 @@ class BrainManager:
# heuristic so "stell auf Englisch um" sets brain.reply_language
# directly (live + persisted) instead of being dispatched as a worker
# mission (2026-06-22 forensic). Provider-independent: no LLM tool-call.
- lang_switch = self._detect_language_switch_intent(user_text)
+ lang_switch = (
+ None if ide_owns_turn else self._detect_language_switch_intent(user_text)
+ )
if lang_switch:
confirmation = self._apply_reply_language_switch(lang_switch)
if confirmation:
@@ -8968,7 +8995,9 @@ class BrainManager:
# reasoning as the language switch: runs BEFORE the force-spawn/LLM path
# so "switch the sub-agent provider to X" sets brain.sub_jarvis.provider
# directly instead of escalating to a worker mission (2026-06-22 forensic).
- subagent_switch = self._detect_subagent_switch_intent(user_text)
+ subagent_switch = (
+ None if ide_owns_turn else self._detect_subagent_switch_intent(user_text)
+ )
if subagent_switch:
confirmation = await self._apply_subagent_provider_switch(subagent_switch)
if confirmation:
@@ -8980,7 +9009,9 @@ class BrainManager:
)
return confirmation
- depth_override = self._detect_depth_override(user_text)
+ depth_override = (
+ None if ide_owns_turn else self._detect_depth_override(user_text)
+ )
if depth_override in ("deep", "fast"):
self._force_level = depth_override
confirmation = self._depth_readback(depth_override)
diff --git a/jarvis/brain/voice_command_gate.py b/jarvis/brain/voice_command_gate.py
index da86410d91..cca9af7762 100644
--- a/jarvis/brain/voice_command_gate.py
+++ b/jarvis/brain/voice_command_gate.py
@@ -113,27 +113,75 @@ _LANG_OUTPUT_VERB = re.compile(
re.IGNORECASE,
)
_LANG_PREP = re.compile(r"\b(?:auf|zu|to|in|on)\b", re.IGNORECASE)
+#: How far from the spoken language word an ingredient may sit and still belong
+#: to the same command. Real switches are compact — a spoken
+#: "stell auf Englisch um" / "antworte ab jetzt auf Englisch" / # i18n-allow: quoted input examples
+#: "respond in German" all fit inside ~35 characters — so this is generous for
+#: anything a user actually says, while far too tight to assemble a command out
+#: of words that merely co-occur somewhere in a dictated paragraph.
+_LANG_WINDOW_CHARS = 60
+_SENTENCE_END_RE = re.compile(r"[.!?]")
+
+
+def _command_window(t: str, start: int, end: int) -> str:
+ """The span around a language word that one switch command could occupy.
+
+ Bounded twice, because either bound alone is too weak: the sentence
+ boundary stops an ingredient in a NEIGHBOURING sentence from counting, and
+ the character window stops one that shares a single, very long dictated
+ sentence with it. See ``_match_language_switch`` for the failure both exist
+ to prevent.
+ """
+ left, right = t[:start], t[end:]
+ boundary = max(left.rfind("."), left.rfind("!"), left.rfind("?"))
+ lo = max(boundary + 1, start - _LANG_WINDOW_CHARS)
+ ahead = _SENTENCE_END_RE.search(right)
+ hi = end + min(ahead.start() if ahead else len(right), _LANG_WINDOW_CHARS)
+ return t[lo:hi]
+
+
+def _language_words(t: str) -> list[tuple[int, int, str]]:
+ """Every spoken language word, in the order the utterance says them.
+
+ ``finditer`` rather than one ``search`` per alias: a language word may be
+ said more than once, and only ONE of those places may be the one carrying
+ the command.
+ """
+ hits: list[tuple[int, int, str]] = []
+ for word, code in _LANG_ALIASES.items():
+ for m in re.finditer(rf"\b{re.escape(word)}\b", t):
+ hits.append((m.start(), m.end(), code))
+ hits.sort()
+ return hits
def _match_language_switch(t: str) -> str | None:
- # Pick the language that appears EARLIEST in the utterance, not the first
- # one in alias-dict order. "antworte auf deutsch und englisch" must resolve # i18n-allow: quoted German input example
- # to de (the first spoken language), not en just because "englisch" happens
- # to sit earlier in _LANG_ALIASES (forensic 2026-06-27).
- best: tuple[int, str] | None = None
- for word, c in _LANG_ALIASES.items():
- m = re.search(rf"\b{re.escape(word)}\b", t)
- if m is not None and (best is None or m.start() < best[0]):
- best = (m.start(), c)
- if best is None:
- return None
- code = best[1]
- if _LANG_CHANGE_VERB.search(t):
- return code
- if _LANG_IMPERATIVE_SPEAK.search(t):
- return code
- if _LANG_OUTPUT_VERB.search(t) and _LANG_PREP.search(t):
- return code
+ """The reply language this utterance switches to, or ``None``.
+
+ Every ingredient is looked for in the WINDOW around the language word, not
+ in the whole utterance. Searching globally is what made this gate claim a
+ turn it had no business in (live 2026-07-28 20:34): a dictated paragraph
+ asking two coding agents for work contained the word for "automatically"
+ (the user DESCRIBING a bug — text is not inserted automatically), the verb
+ "stellen" 408 characters later (from "Rückfragen stellen", i.e. to ASK # i18n-allow: quoted transcript tokens
+ questions) and a preposition somewhere before both. Three unrelated
+ clauses assembled into a language command, the gate answered the turn at
+ once, and the Agentic-IDE delivery path further down ``generate()`` was
+ never reached — so no agent was briefed while the user was told they were.
+
+ The EARLIEST qualifying language still wins, so an utterance naming two
+ languages keeps resolving to the first one spoken (forensic 2026-06-27) —
+ but a language word with no command around it is now skipped rather than
+ deciding the turn.
+ """
+ for start, end, code in _language_words(t):
+ window = _command_window(t, start, end)
+ if _LANG_CHANGE_VERB.search(window):
+ return code
+ if _LANG_IMPERATIVE_SPEAK.search(window):
+ return code
+ if _LANG_OUTPUT_VERB.search(window) and _LANG_PREP.search(window):
+ return code
return None
diff --git a/tests/unit/brain/test_config_gate_vs_agentic_ide_routing.py b/tests/unit/brain/test_config_gate_vs_agentic_ide_routing.py
new file mode 100644
index 0000000000..fa2046cc28
--- /dev/null
+++ b/tests/unit/brain/test_config_gate_vs_agentic_ide_routing.py
@@ -0,0 +1,258 @@
+"""Config-gate-vs-Agentic-IDE routing (a setting word inside a pane order).
+
+Live bug (voice session 2026-07-28 20:34, coding mode ON, six panes open): the
+user asked for two coding agents to be briefed with split work. Jarvis briefed
+neither. It changed ``brain.reply_language`` to ``auto``, persisted that to
+jarvis.toml, and answered the turn — then the live model, which is never told
+any of this, filled the silence by claiming both agents had been given their
+tasks. Nothing was written to any pane and no brain ever saw the request.
+
+Root cause (measured, not guessed): ``BrainManager.generate`` runs the
+deterministic self-configuration gates BEFORE the Agentic-IDE delivery path,
+and ``voice_command_gate._match_language_switch`` searched the WHOLE utterance
+for each ingredient of a language command independently. In this dictated
+paragraph it found "automatisch" at offset 458 (the user DESCRIBING a bug — # i18n-allow: quoted transcript token
+text is not inserted automatically), the verb "stellen" at 866 (from # i18n-allow: quoted transcript token
+"Rückfragen stellen") and an "in" before both: three unrelated clauses, up to # i18n-allow: quoted transcript tokens
+468 characters apart, assembled into "switch the reply language to auto". The
+gate returned, and the delivery path 283 lines further down never ran.
+
+Two independent fixes, one test file:
+
+1. ``_match_language_switch`` binds its ingredients to a window around the
+ language word, so scattered co-occurrence can no longer form a command.
+2. A turn that NAMES A RUNNING PANE outranks the self-configuration gates
+ altogether — the same precedence the desktop gate already honours (see
+ ``test_cu_vs_agentic_ide_routing.py``). Briefing an agent and changing a
+ setting are not things a user can mean at the same time, so however
+ plausible a config match looks, the named agent is the stronger evidence.
+
+The cancel intercept is deliberately NOT behind that precedence: stopping work
+is a safety control and must keep working under every phrasing.
+
+Deterministic throughout: real gate, real detector, faked prompt composer.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from jarvis.agentic_ide import prompt_composer
+from jarvis.agentic_ide import session as session_mod
+from jarvis.agentic_ide.prompt_composer import ComposedPrompt
+from jarvis.agentic_ide.session import Registry
+from jarvis.brain.manager import BrainManager
+from jarvis.brain.voice_command_gate import match_voice_command
+from jarvis.core.bus import EventBus
+from jarvis.core.config import JarvisConfig
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+# The live transcript, trimmed to the part that carries the failure — every
+# word that made the gate fire is kept at its original distance from the
+# others. ``{a}`` and ``{b}`` stand where the user named two panes.
+LIVE_FAILURE = (
+ "Was geht ab? Ähm, kannst du bitte für mich ähm {a} und {b} prompten, " # i18n-allow: German speech input under test
+ "dass sie die Dev machen sollen, alle Funktionalitäten rund um unsere " # i18n-allow: German speech input under test
+ "neues ähm Voice Feature ähm machen so ähm und gucken, welche " # i18n-allow: German speech input under test
+ "Funktionalitäten nicht funktionieren. Ähm, was mir ähm extrem " # i18n-allow: German speech input under test
+ "aufgefallen ist, ist z.B., dass es nicht funktioniert, dass ähm wenn " # i18n-allow: German speech input under test
+ "man überhaupt diese Shortcut-Kombination ähm macht, welche wir in " # i18n-allow: German speech input under test
+ "den in der Einstellungssektion haben, dass es dann nicht automatisch " # i18n-allow: German speech input under test
+ "in das Textfeld reingepromptet wird, ähm wo man drinnen ist. Das " # i18n-allow: German speech input under test
+ "funktioniert nicht. Soll in der Codebase nachschauen, wenn was sie " # i18n-allow: German speech input under test
+ "machen sollen, wenn sie wenn sie das nicht wissen, dann ähm sollen " # i18n-allow: German speech input under test
+ "sie mir Rückfragen stellen. Ähm du musst natürlich die beiden ähm " # i18n-allow: German speech input under test
+ "prompten, dass sie verschiedene Aufgaben machen. Also du splittest " # i18n-allow: German speech input under test
+ "die beiden Aufgaben." # i18n-allow: German speech input under test
+)
+
+
[email protected](autouse=True)
+def _isolated_recents(
+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """Never rewrite the developer's real recent-workspace list from a test."""
+ from jarvis.agentic_ide import recents
+
+ store = tmp_path_factory.mktemp("recents") / "recents.json"
+ monkeypatch.setattr(recents, "_store_path", lambda: store)
+
+
[email protected](autouse=True)
+def _fake_composer(monkeypatch: pytest.MonkeyPatch) -> None:
+ """A deterministic stand-in for the quality-tier prompt writer."""
+
+ async def fake_compose(utterance: str, **kwargs: object) -> ComposedPrompt:
+ name = kwargs["terminal_name"]
+ instruction = kwargs.get("instruction") or utterance
+ return ComposedPrompt(
+ text=f"## Task for {name}\n{instruction}",
+ files=["jarvis/core/bus.py"],
+ composed_by="llm",
+ )
+
+ monkeypatch.setattr(prompt_composer, "compose", fake_compose)
+
+
+def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ reg = Registry(pty_manager=FakePtyManager())
+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)
+ return reg
+
+
+def manager() -> BrainManager:
+ cfg = JarvisConfig()
+ cfg.brain.primary = "fake"
+ mgr = BrainManager(config=cfg, bus=EventBus(), tools={})
+ # Pinned so wording assertions do not depend on the host's locale
+ # (AP-23: never test against the maintainer's own configuration).
+ mgr._reply_language = "en"
+ return mgr
+
+
+async def _noop(_text: str) -> None:
+ return None
+
+
+async def _noop_exit(_code: int) -> None:
+ return None
+
+
+async def _open(registry: Registry, folder: Path, count: int) -> None:
+ """Open ``count`` panes AND bring their agents live."""
+ await registry.start(str(folder), [{"agent": "claude"} for _ in range(count)])
+ assert registry.session is not None
+ for term in list(registry.session.terminals):
+ await registry.attach(term.name, 100, 30, _noop, _noop_exit)
+
+
+def _names(registry: Registry) -> list[str]:
+ assert registry.session is not None
+ return [t.name for t in registry.session.terminals]
+
+
+def _prompted(registry: Registry) -> list[str]:
+ """Every pane that actually received a prompt."""
+ assert registry.session is not None
+ return [t.name for t in registry.session.terminals if t.prompts_sent > 0]
+
+
+def _spoken(registry: Registry) -> str:
+ """The live utterance with the two addressed panes filled in."""
+ names = _names(registry)
+ return LIVE_FAILURE.format(a=names[0], b=names[4])
+
+
+# --------------------------------------------------------------------------- #
+# Fix 1 — the gate may not assemble a command out of scattered words #
+# --------------------------------------------------------------------------- #
+
+
+def test_the_language_gate_no_longer_claims_this_turn() -> None:
+ """The ingredients are all present; only their distance disqualifies them."""
+ assert "automatisch" in LIVE_FAILURE # i18n-allow: quoted transcript token
+ assert "stellen" in LIVE_FAILURE # i18n-allow: quoted transcript token
+
+ m = match_voice_command(LIVE_FAILURE.format(a="T1", b="T5"))
+
+ assert m is None or m.kind != "language_switch"
+
+
+def test_a_real_language_switch_is_untouched() -> None:
+ """The recall side: the gate still exists to catch these."""
+ m = match_voice_command("stell auf Englisch um") # i18n-allow: German speech input under test
+ assert m is not None and m.kind == "language_switch"
+ assert m.target == "en"
+
+
+# --------------------------------------------------------------------------- #
+# Fix 2 — a named pane outranks the self-configuration gates #
+# --------------------------------------------------------------------------- #
+
+
+async def test_the_config_gates_stand_down_while_a_pane_is_addressed(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ """The guard ``generate`` consults before it runs any config gate.
+
+ Asked against a REAL open workspace, because the whole failure was that the
+ config gate never learned a workspace was there.
+ """
+ await _open(registry, tmp_path, 6)
+
+ assert manager._agentic_ide_owns_turn(_spoken(registry)) is True
+
+
+async def test_the_addressed_panes_are_briefed_end_to_end(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ """What the user actually asked for: both named agents get the work.
+
+ The live turn delivered to neither, so this asserts the whole point of the
+ feature — and that the SECOND pane is not lost, which is its own recurring
+ failure mode.
+ """
+ await _open(registry, tmp_path, 6)
+ names = _names(registry)
+
+ reply = await manager._run_agentic_ide_fast_path(_spoken(registry))
+
+ assert reply is not None
+ assert _prompted(registry) == [names[0], names[4]]
+
+
+async def test_a_forced_config_match_still_cannot_take_a_pane_turn(
+ manager: BrainManager,
+ registry: Registry,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The precedence itself, proven independently of the gate's own fix.
+
+ The detector is forced to claim a language switch, so this fails unless
+ ``generate`` really does consult the workspace BEFORE its config gates.
+ Belt and braces on purpose: fix 1 stops this particular sentence, fix 2
+ stops the whole class — some future config gate will match something in a
+ long dictated paragraph again.
+ """
+ await _open(registry, tmp_path, 6)
+ names = _names(registry)
+ applied: list[str] = []
+
+ monkeypatch.setattr(manager, "_detect_language_switch_intent", lambda _t: "en")
+
+ def _record(code: str) -> str:
+ applied.append(code)
+ return "language switched"
+
+ monkeypatch.setattr(manager, "_apply_reply_language_switch", _record)
+
+ await manager.generate(_spoken(registry), use_history=False)
+
+ assert applied == []
+ assert _prompted(registry) == [names[0], names[4]]
+
+
+async def test_a_plain_language_switch_keeps_its_turn_with_panes_open(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ """Having panes open must not withdraw the config gates wholesale.
+
+ An open workspace is the normal state while coding; if it disabled the
+ language switch, "answer in English from now on" would stop working for as
+ long as the IDE is up.
+ """
+ await _open(registry, tmp_path, 6)
+
+ assert manager._agentic_ide_owns_turn("stell auf Englisch um") is False # i18n-allow: German speech input under test
+ m = match_voice_command("stell auf Englisch um") # i18n-allow: German speech input under test
+ assert m is not None and m.kind == "language_switch"
+
+
+async def test_no_workspace_open_changes_nothing(manager: BrainManager) -> None:
+ """With no session at all the guard is inert — the common case."""
+ assert manager._agentic_ide_owns_turn(LIVE_FAILURE.format(a="T1", b="T5")) is False
diff --git a/tests/unit/brain/test_voice_command_gate.py b/tests/unit/brain/test_voice_command_gate.py
index c37ee1d225..5e6c87181f 100644
--- a/tests/unit/brain/test_voice_command_gate.py
+++ b/tests/unit/brain/test_voice_command_gate.py
@@ -189,3 +189,37 @@ def test_language_switch_survives_live_stt_mistranscript() -> None:
)
assert m is not None and m.kind == "language_switch"
assert m.target == "en"
+
+
+def test_language_switch_needs_its_ingredients_in_one_clause() -> None:
+ """A dictated paragraph must not be assembled into a language command.
+
+ Live 2026-07-28 20:34, coding mode on, six panes open: the user asked for
+ two coding agents to be briefed. The utterance happened to contain
+ "automatisch" (describing a bug — text is NOT inserted automatically), the # i18n-allow: quoted German transcript token
+ verb "stellen" 408 characters later (from "Rückfragen stellen") and an "in" # i18n-allow: quoted German transcript tokens
+ before both. The gate searched the WHOLE utterance for each ingredient,
+ assembled them into "switch the reply language to auto", answered the turn
+ and persisted the setting — so ``generate()`` returned before the
+ Agentic-IDE delivery path and no agent was ever briefed, while the live
+ model told the user two of them were working.
+ """
+ m = match_voice_command(
+ "Was mir aufgefallen ist: es funktioniert nicht, dass es dann nicht " # i18n-allow: bug transcript
+ "automatisch in das Textfeld reingepromptet wird. Sie sollen in der " # i18n-allow: bug transcript
+ "Codebase nachschauen, und wenn sie das nicht wissen, dann sollen sie " # i18n-allow: bug transcript
+ "mir Rückfragen stellen." # i18n-allow: bug transcript
+ )
+ assert m is None or m.kind != "language_switch"
+
+
+def test_language_switch_still_matches_across_ordinary_filler() -> None:
+ """The proximity bound must not cost a normally-spoken switch."""
+ for text, target in (
+ ("wechsle die Sprache bitte mal auf Spanisch", "es"), # i18n-allow: German speech-input test vocabulary
+ ("stell die Antwortsprache auf automatisch", "auto"), # i18n-allow: German speech-input test vocabulary
+ ("sprich Spanisch", "es"), # i18n-allow: German speech-input test vocabulary
+ ):
+ m = match_voice_command(text)
+ assert m is not None and m.kind == "language_switch", text
+ assert m.target == target, text