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(brain): send the society reply policy once and cap core memory honestly
rubenluetke10-beepfbac18fa3e62
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex baf9c4fd7a..4762c32c64 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -2397,9 +2397,16 @@ _WRITTEN_CHAT_STYLE = ("with plain-text headers and no emoji column.")+# The written-only rules, for a prompt that already carries the shared policy+# (a society agent's briefing has it under "How to reply to the person").+_WRITTEN_CHAT_RULES = _WRITTEN_CHAT_STYLE+# Keep the API chat and the main brain's written delivery equally conversational._WRITTEN_CHAT_STYLE += "\n" + CONVERSATIONAL_RESPONSE_STYLE+#: Upper bound for the legacy core-memory block in the system prompt.+_CORE_MEMORY_MAX_CHARS = 20_000+def _is_written_turn() -> bool:"""True when the current turn is a typed (written) turn, not voice.@@ -4225,7 +4232,11 @@ class BrainManager:_TOOL_ROUTING_RULES,self._render_live_tool_block(),getattr(self, "_evidence_directive", ""),- _WRITTEN_CHAT_STYLE,+ # The briefing already carries the shared reply policy; sending+ # it twice costs ~2.3k characters on every society API turn.+ _WRITTEN_CHAT_RULES+ if CONVERSATIONAL_RESPONSE_STYLE in (private.system_extra or "")+ else _WRITTEN_CHAT_STYLE,]identity = getattr(self, "_active_turn_identity", None)if identity:@@ -4374,11 +4385,10 @@ class BrainManager:except Exception: # noqa: BLE001passcm = self._core_memory.render_system_prompt_block()- # Cap substantially larger than the old 400 characters — otherwise- # even 5-10 facts get cut off mid-block and the LLM claims it knows- # nothing. 2500 corresponds to ~600 tokens, stays prompt-cache-friendly.- if len(cm) > 2500:- cm = cm[:20_000] + "…"+ # A safety cap only (the 2500-character cost cap was retired): cut,+ # and mark the cut, only when the block really is longer.+ if len(cm) > _CORE_MEMORY_MAX_CHARS:+ cm = cm[:_CORE_MEMORY_MAX_CHARS] + "…"parts.append(cm)# Skills-Brain-Integration (Track B): surface the installed, activediff --git a/tests/unit/agent_chat/test_response_style.py b/tests/unit/agent_chat/test_response_style.pyindex ddea242c7b..06d45a351f 100644--- a/tests/unit/agent_chat/test_response_style.py+++ b/tests/unit/agent_chat/test_response_style.py@@ -2,6 +2,8 @@from pathlib import Path+import pytest+from jarvis.agent_chat import jarvis_harnessfrom jarvis.agent_chat.runner_api import system_promptfrom jarvis.brain.manager import _WRITTEN_CHAT_STYLE@@ -48,3 +50,30 @@ def test_both_voice_personas_include_reporting_without_losing_spoken_rules() ->assert "REPORTING RESULTS" in promptassert "SPOKEN" in promptassert "spell every number" in prompt++[email protected]("briefed", [True, False])+def test_society_api_turn_carries_the_reply_policy_exactly_once(briefed: bool) -> None:+ from types import SimpleNamespace++ from jarvis.brain.manager import _TURN_OVERRIDE, BrainManager+ from jarvis.brain.turn_override import TurnOverride++ briefing = "## How to reply to the person\n" + CONVERSATIONAL_RESPONSE_STYLE+ manager = BrainManager.__new__(BrainManager)+ manager._config = SimpleNamespace(performance=SimpleNamespace(cache_optimized_prompt=True))+ manager._render_live_tool_block = lambda: "TOOLS"+ manager._reply_language_directive = lambda: "LANGUAGE"+ token = _TURN_OVERRIDE.set(+ TurnOverride(+ provider="test",+ system_extra=briefing if briefed else "## Agent\nScout",+ tool_context={"tool_origin": "society"},+ )+ )+ try:+ prompt = manager._build_system_prompt()+ finally:+ _TURN_OVERRIDE.reset(token)+ assert prompt.count(CONVERSATIONAL_RESPONSE_STYLE) == 1+ assert "WRITTEN CHAT STYLE" in prompt