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(realtime): widen the Gemini history-seed fail-open boundary to SDK type construction (BUG-088)
Ruben Lütkec9125ebf0fdd
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex b890e447b2..5e54fc9b3e 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -285,31 +285,34 @@ async def _seed_history(session: Any, history: tuple[dict[str, str], ...]) -> No"""if not history:return- from google.genai import types # lazy (AP-26)+ # The whole seed is one guarded unit — including SDK type construction:+ # a types.Content/Part validation error must degrade exactly like a+ # rejected wire call, never fail the provider handshake.+ try:+ from google.genai import types # lazy (AP-26)- turns = []- for message in history:- if not isinstance(message, dict):- continue- role = str(message.get("role", "") or "")- text = str(message.get("text", "") or "").strip()- if not text or role not in {"user", "assistant"}:- continue- turns.append(- types.Content(- role="user" if role == "user" else "model",- parts=[types.Part(text=text)],+ turns = []+ for message in history:+ if not isinstance(message, dict):+ continue+ role = str(message.get("role", "") or "")+ text = str(message.get("text", "") or "").strip()+ if not text or role not in {"user", "assistant"}:+ continue+ turns.append(+ types.Content(+ role="user" if role == "user" else "model",+ parts=[types.Part(text=text)],+ ))- )- if not turns:- return- try:+ if not turns:+ returnawait session.send_client_content(turns=turns, turn_complete=False)except Exception: # noqa: BLE001 — an amnesiac session beats a dead calllog.warning("gemini-live: seeding %d prior turns into the fresh session ""failed; the conversation continues without in-call context",- len(turns),+ len(history),exc_info=True,)diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 34f8090e12..5226940886 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -2762,8 +2762,12 @@ class RealtimeVoiceSession:if callable(set_snapshot):try:set_snapshot(self._history_seed())- except Exception: # noqa: BLE001, S110 — snapshot is best-effort- pass+ except Exception: # noqa: BLE001 — snapshot is best-effort+ log.debug(+ "realtime[%s] history snapshot update failed",+ self.session_id,+ exc_info=True,+ )def _history_seed(self) -> tuple[dict[str, str], ...]:"""The bounded call transcript in provider-neutral seed form.diff --git a/tests/unit/realtime/test_gemini_live.py b/tests/unit/realtime/test_gemini_live.pyindex 840ae0fc64..692ed333ad 100644--- a/tests/unit/realtime/test_gemini_live.py+++ b/tests/unit/realtime/test_gemini_live.py@@ -612,6 +612,29 @@ async def test_history_seeding_failure_keeps_the_session_alive(assert session is not None+async def test_history_seed_construction_failure_keeps_the_session_alive(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """SDK type construction sits inside the fail-open boundary too: a+ Content/Part validation error must degrade to an amnesiac session,+ never fail the provider handshake."""+ holder = _patch_seedable_genai_client(monkeypatch)++ from google.genai import types++ def _explode(*_args, **_kwargs):+ raise ValueError("SDK validation tightened")++ monkeypatch.setattr(types, "Content", _explode)+ session = await GeminiLiveProvider(api_key="test-key").open_session(+ RealtimeSessionConfig(history=({"role": "user", "text": "hello"},))+ )++ assert session is not None+ assert holder["client"].aio.live.last_cm.client_content_calls == []++# --- function_declarations schema sanitizing --------------------------------