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): stop appending the whole instruction block on every turn
rubenluetke10-beep76b823ad6e43
diff --git a/jarvis/plugins/realtime/codex_subscription.py b/jarvis/plugins/realtime/codex_subscription.pyindex ea9b3755fc..3299dec61e 100644--- a/jarvis/plugins/realtime/codex_subscription.py+++ b/jarvis/plugins/realtime/codex_subscription.py@@ -1809,15 +1809,43 @@ class _CodexSubscriptionRealtimeSession:ChatGPT-Live has no session-instructions field a client may set, butit does accept developer context — which is how the assistant learns- who it is and what this project is. Delivered once per distinct text- so a re-issued identical persona costs nothing.+ who it is and what this project is. The transport is APPEND-only, and+ the session refreshes the full ~20k-char block on every final user+ transcript (its clock line alone changes every minute), so re-sending+ the whole block grew the live thread by a full persona per turn: the+ call got slower with every exchange and the model kept re-reading+ stale copies of per-turn directives. The full block goes out once;+ afterwards only the lines that actually changed are appended, under a+ header that says the rest stays in force."""text = str(instructions or "").strip()if not text or text == self._delivered_context:return+ payload = text+ if self._delivered_context:+ previous_lines = set(self._delivered_context.splitlines())+ changed = [+ line+ for line in text.splitlines()+ if line.strip() and line not in previous_lines+ ]+ if not changed:+ # Only removals or reordering: nothing an append can retract.+ self._delivered_context = text+ return+ payload = "\n".join(+ (+ "Developer context update — only the CHANGED lines "+ "follow; everything else from the previous developer "+ "context stays in force:",+ *changed,+ )+ )try:await self._append_trusted(- lambda: self._client.realtime_append_text(self._thread_id, text, role="developer"),+ lambda: self._client.realtime_append_text(+ self._thread_id, payload, role="developer"+ ),arms_response=False,)except Exception: # noqa: BLE001 - a mute persona must not kill the calldiff --git a/tests/unit/realtime/test_codex_subscription.py b/tests/unit/realtime/test_codex_subscription.pyindex 998af0ddec..bce7b42ae1 100644--- a/tests/unit/realtime/test_codex_subscription.py+++ b/tests/unit/realtime/test_codex_subscription.py@@ -422,6 +422,35 @@ async def test_language_update_is_developer_context_and_speech_is_authoritative(await session.close()+async def test_context_refresh_appends_only_the_changed_lines() -> None:+ """An append-only transport must not receive the full block per turn.++ The session refreshes its ~20k-char instruction block on every final+ user transcript (the clock line alone changes every minute); re-appending+ all of it grew the live thread by a whole persona per exchange.+ """+ client = _Client()+ session = await _provider(client).open_session(+ RealtimeSessionConfig(instructions="Persona line.\nClock: 12:00.")+ )++ await session.update_session(instructions="Persona line.\nClock: 12:01.")++ context_appends = [+ text+ for _thread, text, role in client.text_appends+ if role == "developer" and "Persona line." in text or "Clock" in text+ ]+ assert context_appends[0] == "Persona line.\nClock: 12:00."+ assert len(context_appends) == 2+ update = context_appends[1]+ assert "Clock: 12:01." in update+ assert "Persona line." not in update+ assert "stays in force" in update+ await session.close()++@pytest.mark.asyncioasync def test_open_pins_language_only_for_an_explicit_reply_language() -> None:"""brain.reply_language = de must pin the FIRST reply, auto must not."""