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
feat(learning): Jarvis' learning loop reviews on the Jarvis lead's own seat
rubenluetke10-beep8609eecdf690
diff --git a/docs/jarvis-learning.md b/docs/jarvis-learning.mdindex e993ae916d..a271fa3078 100644--- a/docs/jarvis-learning.md+++ b/docs/jarvis-learning.md@@ -35,11 +35,13 @@ Jarvis itself, tuned for a voice assistant.it, cut to 240 characters) and the two small notebooks. It returns at mostthree changes (`add`, `replace` to update or merge, `remove` only when theuser retracted something), capped at 800 output tokens; proposals below- importance 5 are dropped. The model is each provider's cheap router-tier- model on the wiki's background chain: subscriptions and keyless local- models while a subscription is connected, never the key that pays for the- voice call.-5. **Validate (Python decides).** A change is written only when:+ importance 5 are dropped. The call runs on the Jarvis lead's own seat:+ the provider, model and auth mode the front-page Jarvis chat answers on+ (the Agents selection; a subscription seat through its CLI, an API seat+ on its Agents-tab key). An explicit `[memory.learning].provider` (with its+ `model`) overrides that seat. No other provider is ever asked: a failed+ review is retried after a growing pause, and after four failures in a row+ its turns are dropped with one log line.5. **Validate (Python decides).** A change is written only when:- its `evidence` is a verbatim quote (12 characters or more) of the**user's** own words the review was shown. Anything only the@@ -114,17 +116,17 @@ Compaction (`compact.py`) keeps the files themselves small:4. **Bounded ledger.** `.learning-ledger.jsonl` rotates at 256 KB and keeps oneprevious file, so the audit trail never exceeds about 0.5 MB.-Privacy: reviews send the reviewed turns to the same background provider-chain the wiki extractor already uses for every conversation turn; the loop-adds no new destination. `enabled = false` switches it off.+Privacy: reviews and merges send the reviewed turns only to the provider the+Jarvis chat already talks to (or the explicit `[memory.learning]` override);+the loop adds no new destination. `enabled = false` switches it off.## Cost- An ordinary conversation (requests, questions, small talk): no model call.- "Remember that X": no model call.- A conversation with a personal fact, preference, correction or plan: one- call of roughly 1,300 input tokens and at most 800 output tokens on a cheap- model, preferably on a subscription.+ call of roughly 1,300 input tokens and at most 800 output tokens on the+ Jarvis chat's own seat (on a subscription when the chat runs on one).- Every turn: at most about 650 prompt tokens for the notebooks, usually farless, and byte-stable between reviews so provider prompt caches apply.- Compaction: nothing while a notebook is below 80 percent full; then at mostdiff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex dee0797da2..a3176709cc 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -1876,8 +1876,10 @@ class JarvisLearningConfig(BaseModel):#: stays small. At 125 % new entries are refused until the reviewer merges.user_budget_chars: int = Field(default=1_500, ge=300, le=40_000)memory_budget_chars: int = Field(default=1_000, ge=300, le=40_000)- #: Reviewer provider/model. Empty = the wiki curator's provider on its cheap- #: model, then every other reachable provider (subscriptions before keys).+ #: Reviewer override: a brain provider id and, optionally, its model (the+ #: model applies only together with a provider). Empty = the Jarvis lead's+ #: own seat, the provider, model and auth mode the front-page Jarvis chat+ #: answers on; no other provider is ever asked (``society.seat_brain``).provider: str = ""model: str = ""timeout_s: float = Field(default=90.0, ge=5.0, le=600.0)diff --git a/jarvis/memory/learning/loop.py b/jarvis/memory/learning/loop.pyindex b7918ecbc4..e901005fcf 100644--- a/jarvis/memory/learning/loop.py+++ b/jarvis/memory/learning/loop.py@@ -21,7 +21,9 @@ their own loop and never feed this one.Turns stay pending until a review has really looked at them: a failed orcancelled review hands them back, and a failing reviewer is retried after a-growing pause, never on every turn. Nothing here runs on the voice path.+growing pause, never on every turn. The reviewer asks only the Jarvis lead's+own seat (``review.ModelReviewer``), so after four failed reviews in a row the+turns are dropped with one log line. Nothing here runs on the voice path."""from __future__ import annotations@@ -52,6 +54,10 @@ _MAX_CONVERSATIONS: Final[int] = 32#: Pause after a failed review, doubled per consecutive failure up to the cap._BACKOFF_S: Final[float] = 60.0_BACKOFF_CAP_S: Final[float] = 3_600.0+#: Consecutive failed reviews (the first plus three retries after the pause)+#: after which the turns are dropped. The reviewer asks only the Jarvis seat,+#: so a seat that keeps failing must not keep its turns forever.+_MAX_FAILURES: Final[int] = 4@dataclass@@ -340,7 +346,19 @@ class JarvisLearningLoop:written, answered = await self._review_said(said, reason)finally:conversation.reviewing = False- if not answered:+ if not answered and conversation.failures + 1 >= _MAX_FAILURES:+ # The seat kept failing: give these turns up (turns that+ # arrived meanwhile stay) and start the count afresh.+ log.warning(+ "learning: dropped %d turn(s) of %s after %d failed reviews; "+ "only the Jarvis seat is ever asked",+ count,+ key,+ conversation.failures + 1,+ )+ conversation.failures = 0+ conversation.retry_at = 0.0+ elif not answered:# Hand the turns back for the next attempt, after a pause.conversation.unreviewed = min(conversation.unreviewed + count, _KEEP_TURNS)conversation.failures += 1@@ -564,7 +582,7 @@ def start_learning(config: Any, bus: Any) -> JarvisLearningLoop | None:system=compact.system_prompt,parser=compact.parse,max_tokens=compact.COMPACT_MAX_TOKENS,- label="JarvisLearningCompaction",+ caller="learning-compaction",),)_loop.start(bus)diff --git a/jarvis/memory/learning/review.py b/jarvis/memory/learning/review.pyindex ee49c2b79a..e46d3b09b1 100644--- a/jarvis/memory/learning/review.py+++ b/jarvis/memory/learning/review.py@@ -272,63 +272,62 @@ def validate(class ModelReviewer:- """Ask the background provider chain for proposals.-- The chain is the wiki's (``provider_chain``): the configured pair first,- then every reachable provider, subscriptions before per-token keys while a- subscription is connected. A review is background work nobody waits on.+ """Ask the Jarvis lead's own seat for proposals, and nothing else.++ The seat is the one the front-page Jarvis chat answers on: the Agents+ selection's provider, model and auth mode (``society.seat_brain``;+ maintainer decision 2026-09-30). An explicit ``[memory.learning]``+ provider (with its model) overrides it. When that one seat cannot answer+ the review returns ``None``: the loop's backoff retries it and finally+ drops the turns. No other provider, subscription or key is asked."""def __init__(self,config: Any,*,- registry: Any = None,system: Callable[[], str] = system_prompt,parser: Callable[[str], Any] = parse,max_tokens: int = REVIEW_MAX_TOKENS,- label: str = "JarvisLearningReview",+ caller: str = "learning",) -> None:self._config = config- self._registry = registryself._system = systemself._parse = parserself._max_tokens = max_tokens- self._label = label+ self._caller = caller++ def _live_config(self) -> Any:+ """The config the chat reads its seat from (the brain manager's), else ours."""+ from jarvis.core.runtime_refs import get_brain_manager++ return getattr(get_brain_manager(), "_config", None) or self._config++ def seat(self, config: Any) -> Any:+ """The seat this reviewer asks. Blocking (login and key probes)."""+ from jarvis.society.seat_brain import Seat, jarvis_seat++ cfg = config.memory.learning+ provider = str(cfg.provider or "").strip()+ if provider:+ # The person picked the reviewer for this loop: that provider on+ # its ordinary credential, with its model or its router-tier one.+ return Seat(provider, str(cfg.model or "").strip(), runner="brain", agent_key=False)+ return jarvis_seat(config)async def __call__(self, prompt: str) -> Any | None:- from jarvis.brain.provider_registry import BrainProviderRegistry+ import asyncio+from jarvis.brain.streaming import aggregatefrom jarvis.core.protocols import BrainMessage, BrainRequest- from jarvis.memory.wiki.provider_chain import (- background_wiki_providers,- build_wiki_provider_chain,- complete_with_fallback,- )+ from jarvis.society.seat_brain import SeatUnavailable, seat_brain- cfg = self._config.memory.learning- curator = self._config.memory.wiki.curator- registry = self._registry or BrainProviderRegistry()- available = set(registry.available())- primary = (- str(cfg.provider).strip()- or str(curator.provider).strip()- or str(self._config.brain.primary)- )- chain = build_wiki_provider_chain(- primary=primary,- # Without an explicit pick every rung runs its provider's cheap- # router-tier model: a short JSON verdict needs no frontier model.- model_override=str(cfg.model or ""),- available=available,- credential_ready=(- background_wiki_providers(available=available, config=self._config)- if self._registry is None- else available- ),- )- if not chain:- log.info("learning review: no reachable provider")+ config = self._live_config()+ try:+ seat = await asyncio.to_thread(self.seat, config)+ brain = await seat_brain(config, seat, caller=self._caller)+ except SeatUnavailable as exc:+ log.info("learning review: the Jarvis seat is unavailable (%s)", exc)return Nonerequest = BrainRequest(system=self._system(),@@ -337,27 +336,19 @@ class ModelReviewer:max_tokens=self._max_tokens,stream=True,)-- def _check(agg: Any) -> str | None:- try:- self._parse(agg.text)- except (ValueError, json.JSONDecodeError) as exc:- return f"malformed review: {exc}"- return None-- result = await complete_with_fallback(- registry=registry,- chain=chain,- request=request,- timeout_s=float(cfg.timeout_s),- label=self._label,- aggregate=aggregate,- validate=_check,- record_health=False,- failure_scope="learning",- )- if result is None:+ try:+ agg = await asyncio.wait_for(+ aggregate(brain.complete(request)),+ timeout=float(config.memory.learning.timeout_s),+ )+ result = self._parse(agg.text)+ except Exception as exc: # noqa: BLE001 - a failed attempt; the loop retries later+ # The type only: a provider's error body never reaches a log (AP-34).+ log.warning(+ "learning review: the Jarvis seat %s did not answer (%s)",+ seat.describe(),+ type(exc).__name__,+ )return None- agg, provider = result- log.info("learning review answered by %s", provider)- return self._parse(agg.text)+ log.info("learning review answered on the Jarvis seat %s", seat.describe())+ return resultdiff --git a/tests/unit/memory/learning/test_jarvis_learning.py b/tests/unit/memory/learning/test_jarvis_learning.pyindex 050b324377..f88fcf058e 100644--- a/tests/unit/memory/learning/test_jarvis_learning.py+++ b/tests/unit/memory/learning/test_jarvis_learning.py@@ -416,6 +416,25 @@ async def test_a_failing_reviewer_is_not_retried_on_every_turn(book: JarvisNotebassert loop.pending() == {"voice:g": 3}+async def test_a_seat_that_keeps_failing_drops_the_turns(book: JarvisNotebook) -> None:+ from jarvis.memory.learning import loop as loop_module++ failures = loop_module._MAX_FAILURES+ reviewer = ScriptedReviewer(*([None] * (failures + 1)))+ loop = JarvisLearningLoop(book, reviewer, review_every_turns=50, idle_review_seconds=0)+ loop.record("voice:z", _voice("I usually work late in the evening on weekdays"))+ for _ in range(failures - 1):+ assert await loop.review("voice:z") == 0+ assert loop.pending() == {"voice:z": 1} # handed back for the next try+ assert await loop.review("voice:z") == 0+ assert loop.pending() == {} # given up: only the Jarvis seat is ever asked+ assert len(reviewer.prompts) == failures+ # A later turn starts a fresh count instead of inheriting the old failures.+ loop.record("voice:z", _voice("I always stop at noon on Fridays for football"))+ assert await loop.review("voice:z") == 0+ assert loop.pending() == {"voice:z": 1}++class BlockingReviewer:def __init__(self) -> None:self.started = asyncio.Event()diff --git a/tests/unit/memory/learning/test_learning_seat.py b/tests/unit/memory/learning/test_learning_seat.pynew file mode 100644index 0000000000..a462076013--- /dev/null+++ b/tests/unit/memory/learning/test_learning_seat.py@@ -0,0 +1,124 @@+"""Jarvis' learning loop reviews on the Jarvis lead's own seat, and nothing else.++The seat is the front-page chat's: the Agents selection (``[brain.worker]``)+with its provider, model and auth mode. An explicit ``[memory.learning]``+provider overrides it. A seat that fails asks no other provider; the loop's+backoff retries and finally drops the turns. The registry records every+brain it builds, so "nothing else was asked" is checked by instantiation.+"""++from __future__ import annotations++import logging+from types import SimpleNamespace++import pytest++from jarvis.memory.learning import compact+from jarvis.memory.learning.review import ModelReviewer+from tests.fakes.fake_seat_registry import RecordingRegistry++ALL = ["openai", "gemini", "claude-api", "claude-cli", "codex", "antigravity", "ollama"]+CHANGES = '{"changes": []}'+++def registry(monkeypatch) -> RecordingRegistry:+ from jarvis.brain import resolver+ from jarvis.core import config, runtime_refs++ reg = RecordingRegistry(ALL, replies={name: CHANGES for name in ALL})+ monkeypatch.setattr(resolver, "_get_registry", lambda: reg)+ monkeypatch.setattr(config, "get_jarvis_agent_secret", lambda provider: f"agent-key-{provider}")+ monkeypatch.setattr(runtime_refs, "get_brain_manager", lambda: None)++ def forbidden(*args, **kwargs):+ raise AssertionError("the learning loop asked a subscription resolver")++ monkeypatch.setattr(resolver, "resolve_subscription_brain", forbidden)+ return reg+++def _config(*, worker: str = "", model: str = "", provider: str = "", pinned_model: str = ""):+ return SimpleNamespace(+ brain=SimpleNamespace(+ worker=SimpleNamespace(provider=worker, model=model, reasoning_effort="")+ if worker+ else None,+ providers={},+ ),+ memory=SimpleNamespace(+ learning=SimpleNamespace(provider=provider, model=pinned_model, timeout_s=5.0)+ ),+ )+++async def test_the_review_runs_on_the_agents_selection_api_seat(registry):+ reviewer = ModelReviewer(_config(worker="openai", model="gpt-chosen"))+ assert await reviewer("{}") == []+ assert [(b.name, b.kwargs) for b in registry.built] == [("openai", {"model": "gpt-chosen"})]+ [answer] = registry.answered+ assert answer.secrets == {"openai": "agent-key-openai"}+ assert answer.caller == "learning"+++async def test_a_subscription_selection_reviews_on_that_subscription(registry):+ reviewer = ModelReviewer(_config(worker="codex", model="gpt-5.5"))+ await reviewer("{}")+ [built] = registry.built+ assert built.name == "codex"+ assert built.kwargs["model"] == "gpt-5.5"+ assert built.kwargs["structured_prompts"] is True+ assert registry.answered[0].secrets == {}++[email protected](("signed_in", "expected"), [(True, "claude-cli"), (False, "claude-api")])+async def test_the_claude_slot_follows_the_front_page_chat(+ registry, monkeypatch, signed_in, expected+):+ from jarvis.core import task_agent++ monkeypatch.setattr(task_agent, "_claude_subscription_ready", lambda: signed_in)+ await ModelReviewer(_config(worker="claude-api", model="claude-sonnet-5-5"))("{}")+ assert [(b.name, b.kwargs.get("model")) for b in registry.built] == [+ (expected, "claude-sonnet-5-5")+ ]+++async def test_an_explicit_learning_provider_is_honoured(registry):+ cfg = _config(worker="openai", model="gpt-chosen", provider="gemini", pinned_model="g-pick")+ await ModelReviewer(cfg)("{}")+ assert [(b.name, b.kwargs) for b in registry.built] == [("gemini", {"model": "g-pick"})]+ # The override uses the provider's ordinary credential, not the Agents-tab slot.+ assert registry.answered[0].secrets == {}+++async def test_a_failing_seat_asks_no_other_provider(registry, caplog):+ registry.failing = frozenset({"openai"})+ with caplog.at_level(logging.DEBUG):+ assert await ModelReviewer(_config(worker="openai", model="gpt-chosen"))("{}") is None+ assert registry.built_names() == ["openai"]+ assert "private provider body" not in caplog.text+++async def test_no_seat_means_no_call(registry, monkeypatch):+ from jarvis.local_models import assistant_session++ tier = SimpleNamespace(provider="", model="", ready=False, reason="no agent is connected")+ monkeypatch.setattr(assistant_session, "agents_tier", lambda cfg: tier)+ assert await ModelReviewer(_config())("{}") is None+ assert registry.built == []+++async def test_compaction_runs_on_the_same_seat(registry):+ registry.replies["gemini"] = '{"merged": [], "outdated": []}'+ compactor = ModelReviewer(+ _config(worker="gemini", model="g-chosen"),+ system=compact.system_prompt,+ parser=compact.parse,+ max_tokens=compact.COMPACT_MAX_TOKENS,+ caller="learning-compaction",+ )+ assert await compactor("{}") == {"merged": [], "outdated": []}+ assert [(b.name, b.kwargs) for b in registry.built] == [("gemini", {"model": "g-chosen"})]+ assert registry.answered[0].caller == "learning-compaction"