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: preserve streamed MCP compound replies

Ruben Lütke59489c359689
diff --git a/jarvis/realtime/scrub_gate.py b/jarvis/realtime/scrub_gate.py
index 3f5085a226..0c07b85860 100644
--- a/jarvis/realtime/scrub_gate.py
+++ b/jarvis/realtime/scrub_gate.py
@@ -22,7 +22,12 @@ _HARD_LEAK_ACTIONS = frozenset(
}
)
_RESIDUE_ACTION = "replaced_with_fallback_residue"
-_STREAM_SAFE_RESIDUE_ACTIONS = frozenset({"removed_em_dash"})
+_STREAM_SAFE_RESIDUE_ACTIONS = frozenset(
+ {
+ "removed_em_dash",
+ "removed_engineering_jargon",
+ }
+)
_TRANSCRIPT_TAIL_MAX_CHARS = 4_096
@@ -87,10 +92,11 @@ class ScrubHoldGate:
self._pending_audio_ms = 0.0
return self.fallback_phrase()
if _is_stream_safe_residue(aggregate):
- # A realtime provider may emit punctuation as its own transcript
- # delta. The complete utterance is not available yet, so a benign
- # dash-normalization residue neither authorizes buffered audio nor
- # aborts the response. The next meaningful delta decides.
+ # A realtime provider may emit punctuation or the first half of a
+ # protected compound as its own transcript delta. The complete
+ # utterance is not available yet, so this benign residue neither
+ # authorizes buffered audio nor aborts the response. The next
+ # meaningful delta decides.
return text
self._cleared = True
if _is_stream_safe_residue(result):
@@ -197,7 +203,7 @@ def _restore_edge_whitespace(original: str, cleaned: str) -> str:
def _is_stream_safe_residue(result: ScrubResult) -> bool:
- """Return whether a whole-utterance fallback came from benign punctuation."""
+ """Return whether fallback came from a benign incomplete stream fragment."""
actions = set(result.actions)
residue_sources = actions - {_RESIDUE_ACTION}
return bool(
diff --git a/tests/unit/realtime/test_scrub_gate.py b/tests/unit/realtime/test_scrub_gate.py
index 1c01f74c22..63f0ddffde 100644
--- a/tests/unit/realtime/test_scrub_gate.py
+++ b/tests/unit/realtime/test_scrub_gate.py
@@ -62,6 +62,31 @@ async def test_leading_streaming_dash_waits_for_meaningful_transcript():
assert gate.release_available() == [buffered]
+async def test_streamed_jargon_prefix_can_complete_a_user_facing_compound():
+ """A partial ``MCP-Server`` transcript must not abort a clean reply."""
+ gate = ScrubHoldGate(language="de")
+ first = _chunk(4)
+ jargon = _chunk(8)
+ suffix = _chunk(12)
+
+ opening = "Im Moment sind zwei" # i18n-allow: German runtime transcript under test
+ assert await gate.feed_transcript(opening) == opening
+ assert await gate.push_audio(first) == [first]
+
+ # Realtime providers may split a hyphenated user concept after ``MCP``.
+ # The whole-utterance scrubber correctly preserves ``MCP-Server``, but the
+ # incomplete delta alone is temporarily reduced to residue.
+ assert await gate.feed_transcript(" MCP") == " MCP"
+ assert gate.hard_leak_pending() is False
+ assert await gate.push_audio(jargon) == [jargon]
+
+ ending = "-Server verbunden." # i18n-allow: German runtime transcript under test
+ assert await gate.feed_transcript(ending) == ending
+ assert gate.hard_leak_pending() is False
+ assert await gate.push_audio(suffix) == [suffix]
+
+
@pytest.mark.asyncio
async def test_scrubbed_delta_keeps_its_original_leading_separator():
gate = ScrubHoldGate(language="en")