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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(wake): stop custom-model false-positive storm - verify every custom_onnx hit
Ruben Lütke4fdf11172fdc
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex ceb7253b8a..2c11e8481c 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -3965,23 +3965,30 @@ class SpeechPipeline:leading up to an OpenWakeWord hit actually contained "hey/hi/hallo +jarv". Returns True if the strict prefix is in the transcript.- Failure modes degrade OPEN (return True with a log line) so a- misconfigured STT, a network blip, a rate-limit, or a known- silence/noise hallucination cannot brick the wake — we'd rather accept- the occasional bare-"Jarvis" false positive than have the user shout- into a dead listener. The ONLY no-transcript case that still suppresses- is an EMPTY capture buffer (nothing was recorded). A clear, non-matching- transcript (genuine other speech) also suppresses, preserving the- bare-"Jarvis" BUG-009 guard.+ STT-outage failure modes degrade OPEN (return True with a log line) so+ a misconfigured STT, a network blip, or a rate-limit cannot brick the+ wake — we'd rather accept the occasional false positive than have the+ user shout into a dead listener. A clear, non-matching transcript+ (genuine other speech) suppresses, preserving the bare-"Jarvis"+ BUG-009 guard. How a WORKING STT that heard no speech (empty+ transcript / silence-hallucination boilerplate) is treated depends on+ the engine: the pretrained hey_jarvis path degrades open (forensic+ 2026-06-28 — short real wakes often mis-transcribe to nothing), while+ a user-trained custom_onnx hit SUPPRESSES (live forensic 2026-07-01 —+ such models false-fire on breath/noise, so "no speech heard" is+ evidence of a false fire, not an STT problem)."""if not self._require_hey_prefix:return True- # The STT re-verification exists ONLY for the jarvis family (the- # hey_jarvis model also fires on bare "Jarvis" — BUG-009). A specific- # pretrained model (alexa/mycroft/rhasspy) or a custom model IS its own- # discriminator; re-transcribing with the German-pinned STT would- # mis-spell the wake word and wrongly reject valid hits ("only Hey- # Jarvis works"). Trust the model for those.+ # The STT re-verification runs for the jarvis family (the hey_jarvis+ # model also fires on bare "Jarvis" — BUG-009) AND for user-trained+ # custom_onnx models (live forensic 2026-07-01: a few-shot model scored+ # breath/ambient/other speech up to 1.000 — a false-positive storm;+ # the transcript matched against the phrase's own sound-folded fuzzy+ # matcher is the real discriminator). Only a specific PRETRAINED model+ # (alexa/mycroft/rhasspy) is exempt via verify_prefix=False: those are+ # their own discriminator, and the STT would mis-transcribe the foreign+ # brand word and wrongly reject valid hits.plan = getattr(self, "_wake_plan", None)if plan is not None and not getattr(plan, "verify_prefix", True):return True@@ -3991,9 +3998,9 @@ class SpeechPipeline:)return True# Nothing captured yet (empty ring buffer) — there is genuinely no audio- # to confirm the wake, so reject without an STT round-trip. This is the- # ONLY no-transcript case that suppresses: a NON-empty buffer the STT- # could not turn into text is treated as an outage below (degrade open).+ # to confirm the wake, so reject without an STT round-trip. (Whether a+ # NON-empty buffer with no usable transcript suppresses or degrades+ # open is engine-dependent — see below.)if not pcm_snapshot:return Falsematched, text = await verify_wake_with_stt(@@ -4003,41 +4010,76 @@ class SpeechPipeline:)if matched:return True- text = (text or "").strip()- # Degrade OPEN on a KNOWN STT hallucination. A silence/noise boilerplate- # transcript ("Untertitelung des ZDF, 2020", "Vielen Dank.") means the- # STT failed to transcribe the real audio — NOT that the user didn't say- # the wake word. OWW already fired strongly, so this is the same case as- # the transient-STT-failure path (which degrades open above): accept- # rather than drop a real "Hey Jarvis". Forensic 2026-06-28: short- # "Hey Jarvis" buffers made the verify STT hallucinate these phrases for- # ~half of all valid wakes, so the wake "stopped working" intermittently.+ # A user-trained custom_onnx model is a WEAK discriminator (live+ # forensic 2026-07-01: scores up to 1.000 on breath/ambient/other+ # speech, several activations per minute). For that engine a WORKING+ # STT that heard no wake phrase — an empty transcript or a known+ # silence-hallucination boilerplate — is evidence of a false fire and+ # must SUPPRESS. The pretrained hey_jarvis path keeps its documented+ # degrade-open behaviour (its false fires happen on real speech, so an+ # empty transcript there really does mean the STT failed, forensic+ # 2026-06-28). A genuine STT OUTAGE (text is None) degrades open for+ # BOTH engines: a dead provider must never brick the wake (AP-22).+ custom_model_hit = (+ plan is not None and getattr(plan, "engine", "") == "custom_onnx"+ )+ # Degrade OPEN on a persistent verify-STT failure (Groq 429/503/+ # timeout after retries). OWW already fired strongly on audio we DID+ # capture, so an unreachable STT is a provider problem, not evidence+ # about what the user said. Accepting here keeps the wake alive+ # through a single-provider outage (AP-22 / open-source resilience:+ # one dead provider must never brick a core path, and recovery must be+ # reachable in-app, never via a restart). The documented honesty cost+ # is the occasional false positive while the STT is down.+ if text is None:+ log.info(+ "wake-verify: verify STT unreachable on a strong OWW hit — "+ "accepting (degrade-open; an STT outage must not brick the "+ "wake, AP-22)"+ )+ return True+ text = text.strip()+ # KNOWN STT hallucination boilerplate ("Untertitelung des ZDF, 2020",+ # "Vielen Dank."). Whisper emits these on silence/noise buffers.+ # - custom_onnx: the buffer held silence/noise → the model false-fired+ # on breath/ambient → suppress (fail-closed).+ # - hey_jarvis: forensic 2026-06-28 showed short REAL "Hey Jarvis"+ # buffers hallucinate these for ~half of all valid wakes → accept+ # (degrade-open), else the wake "stops working" intermittently.# An arbitrary non-matching transcript (genuine OTHER speech) still- # suppresses, so the bare-"Jarvis" false-positive guard (BUG-009) stays.+ # suppresses for both, so the bare-"Jarvis" guard (BUG-009) stays.if text and _STT_HALLUCINATION_RE.search(text) is not None:+ if custom_model_hit:+ log.info(+ "wake-verify: suppressed — STT hallucination %r on a "+ "custom-model hit (silence/noise false fire, fail-closed)",+ text[:80],+ )+ return Falselog.info("wake-verify: STT hallucination %r on a strong OWW hit — ""accepting (degrade-open, not a real rejection)",text[:80],)return True- # Degrade OPEN when the verify STT yielded NO usable transcript for real- # captured audio. ``verify_wake_with_stt`` collapses a persistent STT- # failure (Groq 429/503/timeout) AND an empty transcription to "" — and- # since OWW already fired strongly on audio we DID capture, an absent- # transcript is an STT problem, not the user staying silent. Accepting- # here is what keeps the wake alive through a single-provider outage- # (AP-22 / open-source resilience: one dead provider must never brick a- # core path, and recovery must be reachable in-app, never via a restart).- # This is the runtime-failure twin of the hallucination degrade-open just- # above; the documented honesty cost is the occasional bare-"Jarvis"- # false positive while the STT is down. A CLEAR non-matching transcript- # still suppresses below, so the BUG-009 guard is unaffected.+ # The verify STT WORKED and produced an empty transcript.+ # - custom_onnx: no speech in the buffer → breath/noise false fire →+ # suppress. This is the "fires out of nowhere" half of the+ # 2026-07-01 storm.+ # - hey_jarvis: an empty transcription on a strong hit is far more+ # likely a silence-mis-transcription of a short real wake than a+ # spontaneous model fire → accept (degrade-open, forensic+ # 2026-06-28 "Hey Jarvis sometimes stops working entirely").if not text:+ if custom_model_hit:+ log.info(+ "wake-verify: suppressed — empty transcript on a "+ "custom-model hit (no speech captured, fail-closed)"+ )+ return Falselog.info("wake-verify: verify STT returned no transcript on a strong OWW "- "hit — accepting (degrade-open; an STT outage must not brick the "- "wake, AP-22)"+ "hit — accepting (degrade-open)")return Truelog.info(diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.pyindex 3b79a6ae6e..79de7d3ccf 100644--- a/jarvis/speech/wake_phrase.py+++ b/jarvis/speech/wake_phrase.py@@ -223,12 +223,17 @@ class WakeWordPlan:needs_local_whisper: bool # True only for the stt_match pathdegraded: bool # True if we could not honour the requestmessage: str # English status string for logs + UI- # Whether an OpenWakeWord hit needs the second-stage STT prefix check. This- # is ONLY for the jarvis family (the hey_jarvis model also fires on bare- # "Jarvis" — BUG-009). For a specific pretrained model (alexa/mycroft/- # rhasspy) or a custom model, the model IS the discriminator and the German-- # pinned STT would otherwise mis-transcribe the wake word and reject valid- # hits. So verify_prefix is True only when the matcher is the jarvis default.+ # Whether an OpenWakeWord hit needs the second-stage STT prefix check.+ # True for the jarvis family (the hey_jarvis model also fires on bare+ # "Jarvis" — BUG-009) AND for user-trained custom_onnx models (live+ # forensic 2026-07-01: a few-shot/synthetic-data model scored breath,+ # ambient noise and arbitrary speech up to 1.000 — several false+ # activations per minute; the verify transcript, matched against the+ # phrase's own sound-folded fuzzy matcher, is the real discriminator).+ # False only for a specific PRETRAINED model (alexa/mycroft/rhasspy):+ # those are trained on large curated datasets, ARE their own+ # discriminator, and the STT would mis-transcribe the foreign brand word+ # and wrongly reject valid hits.verify_prefix: bool@@ -276,7 +281,14 @@ def resolve_wake_plan(cfg: Any, *, local_whisper_available: bool) -> WakeWordPlaneeds_local_whisper=False,degraded=False,message=f"Custom ONNX wake model: {custom_path}",- verify_prefix=matcher.is_jarvis_default,+ # ALWAYS verify custom-model hits with the STT prefix gate.+ # Live forensic 2026-07-01: trusting the trained model alone+ # ("it IS its own discriminator") caused a false-positive storm+ # — scores up to 1.000 on breath/ambient/other speech. The+ # verifier matches against this phrase's sound-folded fuzzy+ # matcher, so it works for ANY configured wake word and+ # tolerates ASR spelling drift ("Niko" for "Nico").+ verify_prefix=True,)log.warning("Custom wake ONNX not found: %s", custom_path)# fall through — try STT match, else degrade.diff --git a/jarvis/speech/wake_verifier.py b/jarvis/speech/wake_verifier.pyindex c125220c2c..ae6250483e 100644--- a/jarvis/speech/wake_verifier.py+++ b/jarvis/speech/wake_verifier.py@@ -79,20 +79,26 @@ async def verify_wake_with_stt(sample_rate: int = 16_000,language: str | None = "de",matcher: Any | None = None,-) -> tuple[bool, str]:+) -> tuple[bool, str | None]:"""Transcribe ``pcm_bytes`` and check the strict wake prefix.Returns ``(matched, transcript_text)``. ``matched`` is True only when thetranscript contains the full "hey/hi/hallo + jarv" pattern.+ The transcript distinguishes two non-matching cases the caller must treat+ differently: ``""`` means the STT WORKED and heard no speech (evidence of a+ breath/noise-triggered false fire on a weak custom model → suppress), while+ ``None`` means the STT itself failed after retries (a provider outage →+ the caller may degrade open so a dead provider never bricks the wake,+ AP-22).+Robustness contract (AD-OE6): never raise. A transient STT failure (Groq429 / 5xx / timeout) is retried once with a short backoff so a real"Hey Jarvis" is not silently dropped when the cloud STT is momentarily- rate-limited mid-session. Empty PCM, a persistently failing STT, or a clear- non-matching transcript collapse to ``(False, "")`` so the wake loop simply- re-arms — it is always better to ignore one borderline wake than to crash- the listener with a 503, and a Groq outage must not turn every ambient OWW- false-positive into an activation.+ rate-limited mid-session. Empty PCM and a clear non-matching transcript+ collapse to ``(False, "")``; a persistently failing STT to ``(False,+ None)`` — the wake loop simply re-arms in every case, it is always better+ to ignore one borderline wake than to crash the listener with a 503."""if not pcm_bytes:return False, ""@@ -122,7 +128,9 @@ async def verify_wake_with_stt("wake-verify STT failed after %d attempts (%s) — suppressing this OWW hit",_WAKE_VERIFY_RETRIES + 1, last_exc,)- return False, ""+ # None (not "") = STT OUTAGE: lets the caller degrade open on a dead+ # provider (AP-22) while a genuine empty transcription stays "".+ return False, Nonetext = (getattr(transcript, "text", "") or "").strip()matched = transcript_has_hey_prefix(text, matcher)log.info(diff --git a/tests/unit/speech/test_wake_custom_model.py b/tests/unit/speech/test_wake_custom_model.pyindex 62143070b7..cb6e44e6c5 100644--- a/tests/unit/speech/test_wake_custom_model.py+++ b/tests/unit/speech/test_wake_custom_model.py@@ -51,12 +51,16 @@ def test_custom_onnx_threshold_scales_strict_to_sensitive(tmp_path) -> None:assert 0.25 <= sensitive <= 0.35-def test_custom_onnx_no_prefix_verify(tmp_path) -> None:- # A custom model IS its own discriminator — it must NOT run the German STT- # prefix re-verify (that path is only for the jarvis-family OWW model).+def test_custom_onnx_requires_prefix_verify(tmp_path) -> None:+ # Live forensic 2026-07-01 (false-positive storm): a user-trained custom+ # model is a WEAK discriminator — it scored breath/ambient/other speech up+ # to 1.000 and fired several times a minute even at threshold 0.50. Trusting+ # the model alone ("it IS its own discriminator") was the root cause, so a+ # custom_onnx hit MUST run the second-stage STT verify against the phrase's+ # own sound-folded fuzzy matcher (works for ANY configured wake word).from jarvis.speech.wake_phrase import resolve_wake_planmodel = tmp_path / "m.onnx"model.write_bytes(b"onnx")plan = resolve_wake_plan(_cfg(str(model)), local_whisper_available=False)- assert plan.verify_prefix is False+ assert plan.verify_prefix is Truediff --git a/tests/unit/speech/test_wake_prefix_gating.py b/tests/unit/speech/test_wake_prefix_gating.pyindex d2e510e788..95410a0231 100644--- a/tests/unit/speech/test_wake_prefix_gating.py+++ b/tests/unit/speech/test_wake_prefix_gating.py@@ -55,13 +55,19 @@ def _bare_pipeline(*,require_hey_prefix: bool,utterance_stt: object | None,+ wake_plan: object | None = None,+ wake_matcher: object | None = None,) -> SpeechPipeline:"""Build a SpeechPipeline shell without running __init__ — the gate logic- only needs three attributes set, so we avoid the heavy provider wiring.+ only needs a few attributes set, so we avoid the heavy provider wiring."""pipe = SpeechPipeline.__new__(SpeechPipeline)pipe._require_hey_prefix = require_hey_prefixpipe._utterance_stt = utterance_stt+ if wake_plan is not None:+ pipe._wake_plan = wake_plan+ if wake_matcher is not None:+ pipe._wake_matcher = wake_matcherreturn pipe@@ -179,6 +185,95 @@ async def test_gate_degrades_open_when_stt_persistently_fails(monkeypatch) -> Noassert stt.calls >= 1+# ---------------------------------------------------------------------------+# custom_onnx hits: the verify transcript is the REAL discriminator.+#+# Live forensic 2026-07-01 (false-positive storm): a user-trained custom model+# scored breath/ambient/other speech up to 1.000 and activated several times a+# minute even at threshold 0.50, with NO second-stage check (verify_prefix was+# False for custom models). The fix: custom_onnx hits run the STT verify against+# the phrase's own fuzzy matcher, and — unlike the precise pretrained hey_jarvis+# model — "the STT worked but heard no wake phrase" (empty transcript or a known+# silence-hallucination) SUPPRESSES instead of degrading open, because this+# model demonstrably fires on breath/noise. A genuine STT outage still degrades+# open (AP-22: a dead provider must never brick the wake path).+# ---------------------------------------------------------------------------+++def _custom_pipeline(stt: object | None) -> SpeechPipeline:+ from jarvis.speech.wake_phrase import compile_wake_matcher++ return _bare_pipeline(+ require_hey_prefix=True,+ utterance_stt=stt,+ wake_plan=SimpleNamespace(engine="custom_onnx", verify_prefix=True),+ wake_matcher=compile_wake_matcher("Hey Nico"),+ )+++async def test_gate_custom_model_accepts_matching_phrase() -> None:+ stt = _FakeSTT("hey nico wie spät ist es") # i18n-allow+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is True+ assert stt.calls == 1+++async def test_gate_custom_model_accepts_sound_folded_spelling() -> None:+ """ASR spelling drift ("Niko" for "Nico") must still confirm the wake —+ the matcher sound-folds, so verify-on-custom cannot re-break recall."""+ stt = _FakeSTT("Hey Niko")+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is True+++async def test_gate_custom_model_rejects_other_speech() -> None:+ """The exact reported bug: the model fires while the user is just talking.+ A clear non-matching transcript must suppress the activation."""+ stt = _FakeSTT("und dann habe ich ihm gesagt dass das morgen fertig wird") # i18n-allow+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is False+ assert stt.calls == 1+++async def test_gate_custom_model_rejects_empty_transcript(monkeypatch) -> None:+ """The "fires out of nowhere" half of the bug: the model fires on breath /+ noise, the verify STT works fine and hears NO speech. For a custom model an+ empty transcript is evidence of a false fire — suppress, do not degrade open."""+ import jarvis.speech.wake_verifier as wv++ monkeypatch.setattr(wv, "_WAKE_VERIFY_BACKOFF_S", 0.0, raising=False)+ stt = _FakeSTT("")+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is False+ assert stt.calls == 1+++async def test_gate_custom_model_rejects_hallucination_boilerplate() -> None:+ """Silence-hallucination boilerplate ("Vielen Dank.") on a custom-model hit+ means the buffer held silence/noise, not the wake phrase — suppress."""+ stt = _FakeSTT("Vielen Dank.") # i18n-allow+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is False+++async def test_gate_custom_model_degrades_open_on_stt_outage(monkeypatch) -> None:+ """A genuine STT outage (every attempt raises) still degrades open for+ custom models — one dead provider must never brick the wake (AP-22)."""+ import jarvis.speech.wake_verifier as wv++ monkeypatch.setattr(wv, "_WAKE_VERIFY_BACKOFF_S", 0.0, raising=False)+ stt = _RaisingSTT(RuntimeError("groq 503"))+ pipe = _custom_pipeline(stt)++ assert await pipe._verify_oww_hit(PCM_2S_16K) is True+ assert stt.calls >= 1++# ---------------------------------------------------------------------------# Real construction: require_hey_prefix flows from config into the pipeline.# ---------------------------------------------------------------------------diff --git a/tests/unit/speech/test_wake_verifier.py b/tests/unit/speech/test_wake_verifier.pyindex d13541fb43..048bf8a130 100644--- a/tests/unit/speech/test_wake_verifier.py+++ b/tests/unit/speech/test_wake_verifier.py@@ -131,9 +131,13 @@ async def test_verify_returns_false_when_transcript_is_bare_jarvis() -> None:async def test_verify_returns_false_when_transcript_is_empty() -> None:stt = _FakeSTT("")- matched, _ = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)assert matched is False+ # A SUCCESSFUL transcription that heard nothing is "", never None — the+ # caller must be able to tell "no speech in the audio" (suppress a+ # breath-triggered custom-model hit) from "the STT is down" (degrade open).+ assert transcript == ""async def test_verify_returns_false_when_pcm_is_empty() -> None:@@ -153,9 +157,13 @@ async def test_verify_returns_false_on_persistent_stt_exception() -> None:OWW hit so the loop re-arms."""stt = _FakeSTT("ignored", raises=RuntimeError("groq 503"))- matched, _ = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)assert matched is False+ # An STT OUTAGE reports transcript=None (not "") so the caller can degrade+ # open on a dead provider (AP-22) while still suppressing a real+ # empty-transcription on a breath-triggered custom-model hit.+ assert transcript is None# The retry means a persistent error is attempted more than once.assert len(stt.calls) >= 2