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
test(brain,sessions): guard user-selected model passthrough into transcript across all providers
Ruben Lütkebe8278a10b24
diff --git a/tests/unit/brain/test_tier_model_resolution.py b/tests/unit/brain/test_tier_model_resolution.pyindex 77c7896eb6..dcc741fdb8 100644--- a/tests/unit/brain/test_tier_model_resolution.py+++ b/tests/unit/brain/test_tier_model_resolution.py@@ -10,10 +10,22 @@ configured fast model (gemini-3.5-flash). Live evidence: voice_turns row for"""from __future__ import annotations+import pytest+from jarvis.brain.manager import BrainManagerfrom jarvis.core.bus import EventBusfrom jarvis.core.config import load_config+# One representative non-default frontier model per configured brain provider.+# Gemini is only one row — model selection must resolve for EVERY provider.+PROVIDER_FAST_DEEP_CASES = [+ ("claude-api", "claude-haiku-4-5-20251001", "claude-opus-4-8"),+ ("openrouter", "anthropic/claude-sonnet-4.6", "anthropic/claude-opus-4.8"),+ ("openai", "gpt-5.5", "gpt-5.5-pro"),+ ("gemini", "gemini-3.5-flash", "gemini-3.1-pro-preview"),+ ("grok", "grok-4.3", "grok-4.3"),+]+def test_router_keeps_fast_model_when_fallback_is_same_provider() -> None:cfg = load_config()@@ -57,3 +69,65 @@ def test_router_caps_thinking_budget_without_touching_global_config() -> None:assert mgr._config.brain.providers["gemini"].thinking_budget == 0 # router cappedassert cfg.brain.providers["gemini"].thinking_budget is None # global untouched+++def test_user_selected_deep_model_drives_the_deep_chain() -> None:+ """Per-user model selection (2026-06-20): the model the user picks for the+ DEEP tier of a provider must be the one a deep/code turn actually runs on —+ so it is the model published on the brain turn and shown in the transcript.++ Guards the deep axis specifically: the existing tests above only cover the+ fast/router model. The fast-tier resolver is steered by [brain.router].model;+ the deep-tier model is steered by [brain.providers.<p>].deep_model, and the+ router-config build must NOT clobber that selection.+ """+ cfg = load_config()+ cfg.brain.router.provider = "gemini"+ cfg.brain.router.model = "gemini-3.5-flash"+ # The user explicitly picks a non-default deep model for Gemini.+ cfg.brain.providers["gemini"].deep_model = "gemini-3.1-pro-preview"++ mgr = BrainManager.from_tier_config("router", cfg, EventBus())++ assert mgr._deep_model("gemini") == "gemini-3.1-pro-preview"+ # A deep/code turn leads with the user-selected deep model on the active+ # provider — exactly the (provider, model) pair that ends up on+ # BrainTurnCompleted and therefore in VoiceTurnRow.model.+ chain = mgr._build_fallback_chain("deep")+ assert chain[0] == ("gemini", "gemini-3.1-pro-preview")++[email protected]("provider,fast_pick,_deep", PROVIDER_FAST_DEEP_CASES)+def test_user_selected_fast_model_resolves_for_every_provider(+ provider, fast_pick, _deep+) -> None:+ """Gemini is only the example: the fast-tier model the user picks is honoured+ for EVERY brain provider when that provider is the active router brain. The+ fast/router model is steered by [brain.router].model and must survive the+ same-provider-fallback clobber for all of them."""+ cfg = load_config()+ cfg.brain.router.provider = provider+ cfg.brain.router.model = fast_pick+ cfg.brain.router.fallback_provider = provider+ cfg.brain.router.fallback_model = fast_pick++ mgr = BrainManager.from_tier_config("router", cfg, EventBus())++ assert mgr._fast_model(provider) == fast_pick++[email protected]("provider,_fast,deep_pick", PROVIDER_FAST_DEEP_CASES)+def test_user_selected_deep_model_resolves_for_every_provider(+ provider, _fast, deep_pick+) -> None:+ """Gemini is only the example: the deep-tier model selection is honoured for+ EVERY brain provider. _deep_model reads [brain.providers.<p>].deep_model, so+ whatever model the user picks per provider is the one a deep turn runs on+ (and thus the one published on the brain turn and shown in the transcript).+ The router-config build must not clobber deep_model for any provider."""+ cfg = load_config()+ cfg.brain.providers[provider].deep_model = deep_pick++ mgr = BrainManager.from_tier_config("router", cfg, EventBus())++ assert mgr._deep_model(provider) == deep_pickdiff --git a/tests/unit/sessions/test_recorder_model_passthrough.py b/tests/unit/sessions/test_recorder_model_passthrough.pynew file mode 100644index 0000000000..93fd1db018--- /dev/null+++ b/tests/unit/sessions/test_recorder_model_passthrough.py@@ -0,0 +1,154 @@+"""Regression guards for the per-user model-selection feature (2026-06-20).++A sibling session is adding a UI where the user picks the concrete model per+brain provider. Gemini (Flash vs. Pro) is only the worked example — the same+must hold for EVERY brain provider (claude-api, openrouter, openai, gemini,+grok). The transcription view must show the model that REALLY ran, not a+hard-wired default: the recorder takes ``provider``/``model`` verbatim from the+completed brain turn, so the contract is inherently provider-agnostic. These+tests pin that across all providers so a refactor of the selection feature+cannot let the transcript diverge from the executed model for any of them.++Two invariants, each checked for all providers:+ 1. The (provider, model) carried on ``BrainTurnCompleted`` lands verbatim in+ ``VoiceTurnRow`` (the values shown as the transcript badges).+ 2. ``tier`` and ``model`` are independent axes — a fast-tier turn running on a+ deep/Pro model must record BOTH faithfully. No layer may infer the tier+ from the model name (or vice versa).+"""+from __future__ import annotations++import pytest++from jarvis.core.bus import EventBus+from jarvis.core.events import (+ BrainTurnCompleted,+ BrainTurnStarted,+ ListeningStarted,+ TranscriptFinal,+ VoiceSessionEnded,+ VoiceSessionStarted,+)+from jarvis.core.protocols import Transcript+from jarvis.sessions.recorder import SessionRecorder+from jarvis.sessions.store import SessionStore++# One representative (provider, model) per configured brain provider. The model+# names are arbitrary from the recorder's perspective (it is event-driven), so+# these are realistic frontier picks per provider — Gemini is just one row.+PROVIDER_MODEL_CASES = [+ ("claude-api", "claude-opus-4-8"),+ ("openrouter", "anthropic/claude-opus-4.8"),+ ("openai", "gpt-5.5-pro"),+ ("gemini", "gemini-3.1-pro-preview"),+ ("grok", "grok-4.3"),+]+++def _final(text: str, lang: str = "de") -> TranscriptFinal:+ return TranscriptFinal(+ source_layer="speech.stt",+ transcript=Transcript(+ text=text, language=lang, confidence=0.9, is_partial=False+ ),+ )++[email protected]("provider,model", PROVIDER_MODEL_CASES)+async def test_user_selected_model_is_recorded_verbatim(provider, model, tmp_path) -> None:+ """For EVERY provider, the model on the completed brain turn flows 1:1 into+ the row. Uses a non-default model per provider so the test would fail if the+ recorder ever substituted a configured/guessed default instead of the name+ the brain actually reported."""+ store = SessionStore(tmp_path / "sessions.db")+ store.open()+ try:+ bus = EventBus()+ SessionRecorder(store).attach(bus)++ await bus.publish(+ VoiceSessionStarted(+ source_layer="speech.pipeline",+ session_id="s-model",+ wake_keyword="hey_jarvis",+ language="de",+ )+ )+ await bus.publish(ListeningStarted(source_layer="speech"))+ await bus.publish(_final("was geht ab"))+ await bus.publish(+ BrainTurnCompleted(+ source_layer="brain",+ provider=provider,+ model=model,+ finish_reason="stop",+ )+ )+ await bus.publish(+ VoiceSessionEnded(+ source_layer="speech.pipeline",+ session_id="s-model",+ hangup_reason="voice_pattern",+ )+ )++ turns = store.get_turns("s-model")+ assert len(turns) == 1+ assert turns[0].provider == provider+ assert turns[0].model == model+ finally:+ store.close()++[email protected]("provider,model", PROVIDER_MODEL_CASES)+async def test_tier_and_model_are_independent_axes(provider, model, tmp_path) -> None:+ """For EVERY provider, a fast-tier turn may run on a deep/Pro model when the+ user picks that model for the fast tier. Both must be recorded faithfully+ and separately — the transcript must never infer the tier from the model+ name."""+ store = SessionStore(tmp_path / "sessions.db")+ store.open()+ try:+ bus = EventBus()+ SessionRecorder(store).attach(bus)++ await bus.publish(+ VoiceSessionStarted(+ source_layer="speech.pipeline",+ session_id="s-axes",+ wake_keyword="hey_jarvis",+ language="de",+ )+ )+ await bus.publish(ListeningStarted(source_layer="speech"))+ await bus.publish(_final("mask it up"))+ # Router classified this as a fast turn ...+ await bus.publish(+ BrainTurnStarted(source_layer="brain", intent_level="fast")+ )+ # ... but the user selected the deep/Pro model for that provider.+ await bus.publish(+ BrainTurnCompleted(+ source_layer="brain",+ provider=provider,+ model=model,+ finish_reason="stop",+ )+ )+ await bus.publish(+ VoiceSessionEnded(+ source_layer="speech.pipeline",+ session_id="s-axes",+ hangup_reason="voice_pattern",+ )+ )++ turns = store.get_turns("s-axes")+ assert len(turns) == 1+ assert turns[0].tier == "fast"+ assert turns[0].provider == provider+ assert turns[0].model == model+ finally:+ store.close()