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): a rebuilt Gemini session gets the conversation so far, not the one it opened with
rubenluetke10-beepd41e4d63e29c
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex 0bd658e5e8..e5b69eb430 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -1092,8 +1092,38 @@ class GeminiLiveProvider:("google_api_key", "GOOGLE_API_KEY"),)+ # The transcript a transport rebuild replays into the fresh session.+ # Declared at class level so ``VertexLiveProvider`` — and any other+ # subclass that writes its own ``__init__`` — always has a valid default.+ _history_seed: tuple[dict[str, str], ...] = ()+def __init__(self, *, api_key: str | None = None) -> None:self._api_key = (api_key or "").strip()+ self._history_seed = ()++ def set_history_snapshot(self, history: tuple[dict[str, str], ...]) -> None:+ """Refresh the transcript a transport rebuild would restore (BUG-088).++ This adapter has no in-protocol resume and Gemini's server drops the+ Live socket on its own schedule (GoAway, 1006), so ``rebuild_on_+ transport_death`` reopens a fresh session mid-call and re-seeds it.+ Until now the seed could only ever be the ``history`` handed in when+ the call was OPENED: everything said since was gone the moment the+ socket dropped. Live 2026-08-24 10:24, the maintainer's report — "he+ forgot the context after about 50 tokens" — is what that looks like+ from the outside.++ The orchestrator pushes the bounded call transcript here after every+ completed turn (``RealtimeVoiceSession._remember_delegate_turn``); the+ capability is probed, never required (AP-21). Local state only, never+ a wire call.+ """+ self._history_seed = tuple(+ {"role": str(message.get("role", "")), "text": str(message.get("text", ""))}+ for message in (history or ())+ if str(message.get("role", "")) in {"user", "assistant"}+ and str(message.get("text", "")).strip()+ )async def can_open_duplex_session(self) -> bool:return bool(self._api_key)@@ -1196,7 +1226,12 @@ class GeminiLiveProvider:# (BUG-104). Probed by SDK capability, never a model-name pin (AP-21):# an SDK without HistoryConfig cannot seed legally, so it opens an# amnesiac session instead of a doomed one.- history = tuple(getattr(cfg, "history", ()) or ())+ # The live snapshot wins over the open-time config: on a mid-call+ # rebuild ``cfg`` still carries the history the CALL started with, so+ # preferring it would replay a stale transcript and drop everything+ # said since. Falls back to cfg for the first open, when no turn has+ # completed yet and the snapshot is legitimately empty.+ history = self._history_seed or tuple(getattr(cfg, "history", ()) or ())history_config_cls = getattr(types, "HistoryConfig", None)seed_declared = bool(history) and history_config_cls is not Noneif history and not seed_declared:diff --git a/tests/unit/realtime/test_gemini_live.py b/tests/unit/realtime/test_gemini_live.pyindex 2f6b11fe59..c650c01c3a 100644--- a/tests/unit/realtime/test_gemini_live.py+++ b/tests/unit/realtime/test_gemini_live.py@@ -7,7 +7,11 @@ from types import SimpleNamespaceimport pytestfrom jarvis.brain.model_catalog import REALTIME_MODELS-from jarvis.plugins.realtime.gemini_live import GeminiLiveProvider, _GeminiLiveSession+from jarvis.plugins.realtime.gemini_live import (+ GeminiLiveProvider,+ VertexLiveProvider,+ _GeminiLiveSession,+)from jarvis.realtime.protocol import RealtimeSessionConfig@@ -1838,3 +1842,63 @@ async def test_a_second_empty_boundary_after_a_supersede_is_not_withheld() -> No"interrupted","turn_complete",]+++# ── transport rebuild must not cost the conversation (BUG-088 parity) ──────+++def test_provider_accepts_a_history_snapshot() -> None:+ """The orchestrator's optional capability must actually be here.++ Gemini drops the Live socket on its own schedule and this adapter has no+ in-protocol resume, so ``rebuild_on_transport_death`` reopens a fresh+ session mid-call. Without this method the reopened session could only be+ seeded with the history the CALL STARTED WITH — every turn since was+ lost, which the maintainer experienced on 2026-08-24 10:24 as Jarvis+ forgetting a task he had restated one turn earlier.+ """+ provider = GeminiLiveProvider(api_key="test-key")+ assert provider._history_seed == ()++ provider.set_history_snapshot(+ (+ {"role": "user", "text": "spawn a sub agent for my morning briefing"},+ {"role": "assistant", "text": "Starting one now."},+ )+ )++ assert provider._history_seed == (+ {"role": "user", "text": "spawn a sub agent for my morning briefing"},+ {"role": "assistant", "text": "Starting one now."},+ )+++def test_history_snapshot_drops_unusable_entries() -> None:+ """Only user/assistant turns with real text reach the seed."""+ provider = GeminiLiveProvider(api_key="test-key")+ provider.set_history_snapshot(+ (+ {"role": "system", "text": "not a conversation turn"},+ {"role": "user", "text": " "},+ {"role": "assistant", "text": "kept"},+ )+ )+ assert provider._history_seed == ({"role": "assistant", "text": "kept"},)+++def test_every_rebuilding_adapter_can_take_a_snapshot() -> None:+ """Capability parity, not a provider-name check (AP-21).++ An adapter that rebuilds its transport mid-call MUST be able to take the+ updated transcript, or the rebuild silently costs the conversation. Pins+ the pair together so a future rebuilding adapter cannot ship without it.+ """+ for provider in (+ GeminiLiveProvider(api_key="test-key"),+ VertexLiveProvider(api_key="test-key"),+ ):+ if getattr(provider, "rebuild_on_transport_death", False):+ assert callable(getattr(provider, "set_history_snapshot", None)), (+ f"{type(provider).__name__} rebuilds its transport but cannot "+ "restore the conversation into the fresh session"+ )