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
refactor(backend): provider-chain, worker routing & config-writer work
Ruben Lütke7c460fae5ed3
diff --git a/jarvis/brain/app_control.py b/jarvis/brain/app_control.pyindex a31aaa654a..eb5b0f2ae6 100644--- a/jarvis/brain/app_control.py+++ b/jarvis/brain/app_control.py@@ -250,7 +250,7 @@ def build_settings_snapshot(cfg: Any) -> dict[str, Any]:wake = getattr(cfg, "wake", None) or getattr(cfg, "wakeword", None)autostart = getattr(cfg, "autostart", None)computer_use = getattr(cfg, "computer_use", None)- sub_jarvis = getattr(brain, "sub_jarvis", None) if brain is not None else None+ sub_jarvis = getattr(brain, "worker", None) if brain is not None else Noneactive_brain = getattr(brain, "primary", None) if brain is not None else None# Prefer the *live* active provider when the BrainManager is running — it is@@ -348,7 +348,7 @@ def _current_provider(cfg: Any, tier: str) -> str | None:if tier == "stt":return getattr(getattr(cfg, "stt", None), "provider", None)if tier == "subagent":- sub = getattr(brain, "sub_jarvis", None) if brain else None+ sub = getattr(brain, "worker", None) if brain else Nonereturn getattr(sub, "provider", None) if sub else Nonereturn None@@ -572,12 +572,12 @@ async def _switch_subagent(}persisted = (_persist(- lambda: _import_writer().set_sub_jarvis_provider(CODEX_SUBAGENT_CANONICAL)+ lambda: _import_writer().set_worker_provider(CODEX_SUBAGENT_CANONICAL))if persistelse False)- _set_in_memory(cfg, ["brain", "sub_jarvis", "provider"], CODEX_SUBAGENT_CANONICAL)+ _set_in_memory(cfg, ["brain", "worker", "provider"], CODEX_SUBAGENT_CANONICAL)return {"ok": True,"tier": "subagent",@@ -607,7 +607,7 @@ async def _switch_subagent(}persisted = (_persist(- lambda: _import_writer().set_sub_jarvis_provider(+ lambda: _import_writer().set_worker_provider(ANTIGRAVITY_SUBAGENT_CANONICAL))@@ -615,7 +615,7 @@ async def _switch_subagent(else False)_set_in_memory(- cfg, ["brain", "sub_jarvis", "provider"], ANTIGRAVITY_SUBAGENT_CANONICAL+ cfg, ["brain", "worker", "provider"], ANTIGRAVITY_SUBAGENT_CANONICAL)return {"ok": True,@@ -652,9 +652,9 @@ async def _switch_subagent(}persisted = (- _persist(lambda: _import_writer().set_sub_jarvis_provider(canon)) if persist else False+ _persist(lambda: _import_writer().set_worker_provider(canon)) if persist else False)- _set_in_memory(cfg, ["brain", "sub_jarvis", "provider"], canon)+ _set_in_memory(cfg, ["brain", "worker", "provider"], canon)return {"ok": True,"tier": "subagent",diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.pyindex 470f401ae3..60e5c7158a 100644--- a/jarvis/brain/factory.py+++ b/jarvis/brain/factory.py@@ -215,27 +215,38 @@ SELF_MOD_TOOL_NAMES_ROUTER = frozenset({def warn_if_phantom_worker_harness(config: Any, harness_manager: Any) -> bool:- """Log a warning when ``[harness.openclaw].enabled`` is true but unregistered.+ """Log a warning when ``[harness.jarvis_agent].enabled`` is true but unregistered.OpenClaw was removed in Welle 4 and has no entry-point, so an``enabled = true`` block is INERT (config honesty, 2026-06-28). This probe isadvisory only: it never raises, never changes routing, and "start a subagent"routes to ``spawn_worker`` regardless. Returns True when a phantom config wasdetected (consumed by the regression guard in tests).++ The config field was renamed from ``harness.openclaw`` to ``harness.jarvis_agent``+ in the 2026-06-29 Jarvis-Agents rename; both TOML keys are accepted via+ AliasChoices in HarnessConfig. The harness-availability slug string "openclaw"+ is left unchanged because the external openclaw binary keeps its name."""- oc = getattr(getattr(config, "harness", None), "openclaw", None)+ # Field renamed openclaw → jarvis_agent; back-compat: also check old attribute+ # name in case a partially-upgraded in-memory config is passed.+ oc = getattr(getattr(config, "harness", None), "jarvis_agent", None)+ if oc is None:+ oc = getattr(getattr(config, "harness", None), "openclaw", None)if oc is None or not getattr(oc, "enabled", False):return Falsetry:available = harness_manager.available()except Exception: # noqa: BLE001 — an advisory probe must never break bootreturn False+ # The harness registration slug is still "openclaw" (external binary keeps its+ # name); if it ever gets registered, the warning becomes a no-op.if "openclaw" in available:return Falselog.warning(- "[harness.openclaw].enabled is true but 'openclaw' is not a registered "- "harness (available: %s) — the block is inert. Heavy sub-agent work runs "- "through spawn_worker; set [harness.openclaw].enabled = false to silence "+ "[harness.jarvis_agent].enabled is true but 'openclaw' is not a registered "+ "harness (available: %s) — the block is inert. Heavy Jarvis-Agent work runs "+ "through spawn_worker; set [harness.jarvis_agent].enabled = false to silence ""this.",available,)diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex d1c332809b..5c1365ad97 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -4399,7 +4399,7 @@ class BrainManager:factory may fall back to the Gemini API worker, which 403s on an accountwithout Gemini access (the original BUG-017, 2026-05-13)."""try:- sub = getattr(self._config.brain, "sub_jarvis", None)+ sub = getattr(self._config.brain, "worker", None)worker_provider = (getattr(sub, "provider", "") or "").strip().lower()except Exception: # noqa: BLE001 — config hiccup must not block dispatchreturn Truediff --git a/jarvis/brain/resolver.py b/jarvis/brain/resolver.pyindex 11b67463c1..da32ea57a7 100644--- a/jarvis/brain/resolver.py+++ b/jarvis/brain/resolver.py@@ -172,11 +172,12 @@ def _resolve_chain(config: JarvisConfig) -> list[tuple[str, str | None]]:chain.append((bio_cfg.override_provider, bio_cfg.override_model or None))brain_cfg = config.brain- # Wave 4 migration: the ``sub_jarvis`` field on BrainConfig was marked- # as legacy (see core/config.py). We still read it if a configuration- # still contains ``[brain.sub_jarvis]`` — it serves as a frontier hint- # for ``resolve_frontier_brain``.- sub_tier = brain_cfg.sub_jarvis+ # Wave 4 migration / 2026-06-29 Jarvis-Agents rename: the field was+ # ``sub_jarvis``, now ``worker`` (accepts old key via AliasChoices). We+ # still read it if a configuration contains ``[brain.worker]`` or the+ # legacy ``[brain.sub_jarvis]`` — it serves as a frontier hint for+ # ``resolve_frontier_brain``.+ sub_tier = brain_cfg.worker# Stage 2 — legacy sub-jarvis tier config from Wave 3 / pre-Wave-4# (user had explicitly set the frontier tier there; remains readable)diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex e0e5da38dd..0a86edcc89 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -21,7 +21,7 @@ from pathlib import Pathfrom typing import TYPE_CHECKING, Any, Literalimport yaml-from pydantic import BaseModel, ConfigDict, Field, field_validator+from pydantic import AliasChoices, BaseModel, ConfigDict, Field, field_validator# wake_constants is pure stdlib (no jarvis imports) — safe to import from this# foundational config module without a cycle. Single source of truth for the@@ -647,6 +647,10 @@ class EvidenceDomainsConfig(BaseModel):class BrainConfig(BaseModel):+ # populate_by_name=True lets callers use the Python field name alongside the+ # validation aliases (needed so both new and old TOML keys populate the fields).+ model_config = ConfigDict(populate_by_name=True)+primary: str = "claude-api"# For deep/code intents an API-key provider can be preferred.deep_brain: str | None = None@@ -668,12 +672,17 @@ class BrainConfig(BaseModel):# Phase 5 tiered routing — Wave-4 migration: the ``sub_jarvis`` tier was# replaced by the OpenClaw bridge (see docs/openclaw-bridge.md §11).# Only ``router`` remains as a tier; the heavy worker runs as an external- # subprocess via Mission Manager. The ``sub_jarvis`` field is kept with a- # default of ``None`` so that old ``[brain.sub_jarvis]`` blocks in- # jarvis.toml do not cause a Pydantic validation error — the values are- # ignored regardless.+ # subprocess via Mission Manager. The ``worker`` field (renamed from+ # ``sub_jarvis`` in the Jarvis-Agents rename, 2026-06-29) accepts both the+ # new TOML key ``[brain.worker]`` and the old ``[brain.sub_jarvis]`` key+ # via AliasChoices so pre-rename installs keep working.router: BrainTierConfig | None = None- sub_jarvis: BrainTierConfig | None = None # legacy, ignored post-Wave-4+ # ``validation_alias`` back-compat: old installs use [brain.sub_jarvis];+ # new installs use [brain.worker]. Both populate this field transparently.+ worker: BrainTierConfig | None = Field(+ default=None,+ validation_alias=AliasChoices("worker", "sub_jarvis"),+ )# User-facing reply language pin (desktop "Languages" view → Reply Language).# "auto" mirrors the user's input language (DE/EN/ES); "de"/"en"/"es" force# that language as a hard rule for every Jarvis reply. Consumed by@@ -1009,6 +1018,10 @@ class JarvisAgentHarnessConfig(BaseModel):class HarnessConfig(BaseModel):"""Config for the harness dispatcher (Phase 4)."""+ # populate_by_name=True lets callers use the Python field name alongside+ # validation aliases for the renamed openclaw → jarvis_agent field.+ model_config = ConfigDict(populate_by_name=True)+enabled: list[str] = Field(default_factory=lambda: ["python-script", "mcp-remote"])@@ -1021,7 +1034,12 @@ class HarnessConfig(BaseModel):per_harness: dict[str, dict[str, object]] = Field(default_factory=dict)# Jarvis-Agent worker harness (Wave 2). None = block missing in jarvis.toml,# bridge stays inactive. When the block is present, ``version`` is required.- openclaw: JarvisAgentHarnessConfig | None = None+ # ``validation_alias`` back-compat: old installs use [harness.openclaw];+ # new installs use [harness.jarvis_agent]. Both populate this field.+ jarvis_agent: JarvisAgentHarnessConfig | None = Field(+ default=None,+ validation_alias=AliasChoices("jarvis_agent", "openclaw"),+ )class MCPServerConfig(BaseModel):@@ -1896,6 +1914,10 @@ class TeamProxyConfig(BaseModel):class JarvisConfig(BaseModel):"""Root config model."""+ # populate_by_name=True lets callers use Python field names alongside+ # validation aliases for the renamed sub_agents → jarvis_agents field.+ model_config = ConfigDict(populate_by_name=True)+profile: ProfileConfig = Field(default_factory=ProfileConfig)persona: PersonaConfig = Field(default_factory=PersonaConfig)trigger: TriggerConfig = Field(default_factory=TriggerConfig)@@ -1915,7 +1937,12 @@ class JarvisConfig(BaseModel):autostart: AutostartConfig = Field(default_factory=AutostartConfig)telemetry: TelemetryConfig = Field(default_factory=TelemetryConfig)security: SecurityConfig = Field(default_factory=SecurityConfig)- sub_agents: JarvisAgentsOutputConfig = Field(default_factory=JarvisAgentsOutputConfig)+ # ``validation_alias`` back-compat: old installs use [sub_agents];+ # new installs use [jarvis_agents]. Both populate this field transparently.+ jarvis_agents: JarvisAgentsOutputConfig = Field(+ default_factory=JarvisAgentsOutputConfig,+ validation_alias=AliasChoices("jarvis_agents", "sub_agents"),+ )integrations: IntegrationsConfig = Field(default_factory=IntegrationsConfig)# Wave 2 — plugin-marketplace OAuth connect (hosted vs loopback callback).marketplace: MarketplaceConfig = Field(default_factory=MarketplaceConfig)@@ -2007,6 +2034,11 @@ def _deep_merge(base: dict[str, Any], overlay: dict[str, Any]) -> dict[str, Any]# cartesia reverting to gemini-flash-tts on every restart._PERSISTED_PROVIDER_ENV_KEYS: tuple[str, ...] = ("JARVIS__BRAIN__PRIMARY",+ # Post-rename name (2026-06-29 Jarvis-Agents rename): config_writer now+ # writes to this key; the drift-guard / boot-heal reads it going forward.+ "JARVIS__BRAIN__WORKER__PROVIDER",+ # Back-compat: pre-rename installs have this key in the Windows registry.+ # Kept so refresh_persisted_env_from_user_registry still heals it at boot."JARVIS__BRAIN__SUB_JARVIS__PROVIDER","JARVIS__TTS__PROVIDER","JARVIS__STT__PROVIDER",@@ -2120,6 +2152,24 @@ def _coerce_env_value(v: str) -> Any:return v+def _migrate_worker_env_vars() -> None:+ """Process-local back-compat shim for the sub_jarvis → worker rename.++ If the OLD env vars (JARVIS__BRAIN__SUB_JARVIS__*) are set in os.environ+ but the NEW ones (JARVIS__BRAIN__WORKER__*) are not, copy old → new so+ _apply_env_overrides and pydantic's AliasChoices both see the expected+ values. This is process-local only (os.environ, NOT setx/registry).+ Called once from load_config before _apply_env_overrides.+ """+ for old_name, new_name in (+ ("JARVIS__BRAIN__SUB_JARVIS__PROVIDER", "JARVIS__BRAIN__WORKER__PROVIDER"),+ ("JARVIS__BRAIN__SUB_JARVIS__MODEL", "JARVIS__BRAIN__WORKER__MODEL"),+ ):+ old_val = os.environ.get(old_name)+ if old_val and not os.environ.get(new_name):+ os.environ[new_name] = old_val # process-local only, no setx++def load_config(config_file: Path | None = None,profile: str | None = None,@@ -2151,6 +2201,9 @@ def load_config(if profile_file.exists():data = _deep_merge(data, _load_yaml(profile_file))+ # Back-compat shim: copy old JARVIS__BRAIN__SUB_JARVIS__* to new+ # JARVIS__BRAIN__WORKER__* if only the old names are set (process-local).+ _migrate_worker_env_vars()data = _apply_env_overrides(data)return JarvisConfig(**data)diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex 93ef7c6747..ff1a627198 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -40,12 +40,17 @@ _BOM = ""# stale env value silently reverts the switch on the next start._BRAIN_PRIMARY_ENV = "JARVIS__BRAIN__PRIMARY"-# Canonical User-scope ENV var that overrides ``[brain.sub_jarvis] provider``+# Canonical User-scope ENV var that overrides ``[brain.worker] provider``# at boot. ``_apply_env_overrides`` splits on ``__`` and lower-cases, so-# ``JARVIS__BRAIN__SUB_JARVIS__PROVIDER`` -> ``brain.sub_jarvis.provider``-# (``sub_jarvis`` survives because it carries only a single underscore).-_SUB_JARVIS_PROVIDER_ENV = "JARVIS__BRAIN__SUB_JARVIS__PROVIDER"-_SUB_JARVIS_MODEL_ENV = "JARVIS__BRAIN__SUB_JARVIS__MODEL"+# ``JARVIS__BRAIN__WORKER__PROVIDER`` -> ``brain.worker.provider``+# (renamed from JARVIS__BRAIN__SUB_JARVIS__PROVIDER in the 2026-06-29+# Jarvis-Agents rename; the old var is accepted via AliasChoices + migration shim).+_WORKER_PROVIDER_ENV = "JARVIS__BRAIN__WORKER__PROVIDER"+_WORKER_MODEL_ENV = "JARVIS__BRAIN__WORKER__MODEL"+# Back-compat aliases for the old ENV var names — kept so any code that+# references these constants by name still resolves without an ImportError.+_SUB_JARVIS_PROVIDER_ENV = _WORKER_PROVIDER_ENV # back-compat alias (pre-rename)+_SUB_JARVIS_MODEL_ENV = _WORKER_MODEL_ENV # back-compat alias (pre-rename)# Canonical User-scope ENV vars that override ``[tts] provider`` / ``[stt]# provider`` at boot. Both section + key are single words, so@@ -84,21 +89,21 @@ def set_brain_primary(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:_sync_brain_primary_drift_soll(name)-def set_sub_jarvis_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:- """Set ``[brain.sub_jarvis] provider`` (the Heavy-Task SUBAGENT provider)+def set_worker_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:+ """Set ``[brain.worker] provider`` (the Heavy-Task Jarvis-Agent provider)across all persistence layers.This is the AUTHORITATIVE writer for the user's subagent-provider choiceand the write-side counterpart to the read-side resolution in- ``jarvis.missions.openclaw.provider_map.canonical_subagent_provider`` /- ``jarvis.missions.init._worker_factory``. The subagent provider is pinned- in ``config-soll.json`` (``brain.sub_jarvis.provider``), so a switch that+ ``jarvis.missions.worker_runtime.provider_map.canonical_worker_provider`` /+ ``jarvis.missions.init._worker_factory``. The worker provider is pinned+ in ``config-soll.json`` (``brain.worker.provider``), so a switch thatwrote only the TOML would be reverted by the drift-guard within minutes —the same failure mode that hit ``brain.primary`` before it went 3-layer.- 1. ``jarvis.toml`` ``[brain.sub_jarvis] provider`` (TOML)- 2. ``scripts/config-soll.json`` ``brain.sub_jarvis.provider`` (drift-soll)- 3. ``JARVIS__BRAIN__SUB_JARVIS__PROVIDER`` User-scope ENV var (boot override)+ 1. ``jarvis.toml`` ``[brain.worker] provider`` (TOML)+ 2. ``scripts/config-soll.json`` ``brain.worker.provider`` (drift-soll)+ 3. ``JARVIS__BRAIN__WORKER__PROVIDER`` User-scope ENV var (boot override)Raises ``FileNotFoundError`` if the TOML config file does not exist. Layers2 + 3 are best-effort cloud-first enhancements: graceful no-op on a headless@@ -107,41 +112,55 @@ def set_sub_jarvis_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> NNB: this writes only ``provider``. The fallback chain(``fallback_provider`` etc.) is left untouched, mirroring how the brainswitch leaves ``[brain]`` siblings alone.++ Renamed from ``set_sub_jarvis_provider`` in the 2026-06-29 Jarvis-Agents+ rename. The old name is preserved as a back-compat alias below."""# Layer 1 — universal, runs on every platform. May raise FileNotFoundError.- _patch_sub_jarvis_provider_toml(path, name)+ _patch_worker_provider_toml(path, name)# Layers 2 + 3 — best-effort, never raise.- _sync_sub_jarvis_provider_drift_soll(name)+ _sync_worker_provider_drift_soll(name)++# Back-compat alias — callers that imported set_sub_jarvis_provider still work.+set_sub_jarvis_provider = set_worker_provider-def set_sub_jarvis_model(model: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:- """Set ``[brain.sub_jarvis] model`` (the dedicated subagent LLM override)++def set_worker_model(model: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:+ """Set ``[brain.worker] model`` (the dedicated Jarvis-Agent LLM override)across all persistence layers.The write-side counterpart to the read-side resolution in``jarvis.missions.workers.provider_chain._resolve_provider_chain`` (the- worker's primary model) and the ``/api/openclaw/status`` ``model_resolved``- display. Empty string is the documented sentinel: the active subagent+ worker's primary model) and the ``/api/jarvis-agent/status`` ``model_resolved``+ display. Empty string is the documented sentinel: the active workerprovider's ``deep_model`` (frontier) wins.- ``brain.sub_jarvis.model`` is pinned in ``config-soll.json`` like the+ ``brain.worker.model`` is pinned in ``config-soll.json`` like theprovider, so a TOML-only write would be reverted by the drift-guard withinminutes (BUG-010 class). Three layers, same shape as- :func:`set_sub_jarvis_provider`:+ :func:`set_worker_provider`:- 1. ``jarvis.toml`` ``[brain.sub_jarvis] model`` (TOML)- 2. ``scripts/config-soll.json`` ``brain.sub_jarvis.model`` (drift-soll)- 3. ``JARVIS__BRAIN__SUB_JARVIS__MODEL`` User-scope ENV var (boot override)+ 1. ``jarvis.toml`` ``[brain.worker] model`` (TOML)+ 2. ``scripts/config-soll.json`` ``brain.worker.model`` (drift-soll)+ 3. ``JARVIS__BRAIN__WORKER__MODEL`` User-scope ENV var (boot override)Layers 2 + 3 are best-effort cloud-first enhancements: graceful no-op on aheadless Linux VPS and never raise out of this function nor break the TOMLwrite. Takes effect for the NEXT mission (the worker resolves its chain perspawn).++ Renamed from ``set_sub_jarvis_model`` in the 2026-06-29 Jarvis-Agents rename.+ The old name is preserved as a back-compat alias below."""# Layer 1 — universal, runs on every platform. May raise FileNotFoundError.- _patch_sub_jarvis_key_toml(path, "model", model)+ _patch_worker_key_toml(path, "model", model)# Layers 2 + 3 — best-effort, never raise.- _sync_sub_jarvis_model_drift_soll(model)+ _sync_worker_model_drift_soll(model)+++# Back-compat alias — callers that imported set_sub_jarvis_model still work.+set_sub_jarvis_model = set_worker_modeldef set_tts_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:@@ -1081,14 +1100,19 @@ def _patch_table(path: Path, table: str, key: str, value: str | bool | list[str]_atomic_write(path, out)-def _patch_sub_jarvis_provider_toml(path: Path, name: str) -> None:- """Set ``[brain.sub_jarvis] provider = name`` in the TOML.+def _patch_worker_provider_toml(path: Path, name: str) -> None:+ """Set ``[brain.worker] provider = name`` in the TOML.- Unlike :func:`_patch_table`, this walks the NESTED ``brain`` -> ``sub_jarvis``- path instead of treating ``"brain.sub_jarvis"`` as a flat top-level key- (``doc.get("brain.sub_jarvis")`` would create a literal dotted key, not the- ``[brain.sub_jarvis]`` section). Creates either level if missing. Preserves+ Unlike :func:`_patch_table`, this walks the NESTED ``brain`` -> ``worker``+ path instead of treating ``"brain.worker"`` as a flat top-level key+ (``doc.get("brain.worker")`` would create a literal dotted key, not the+ ``[brain.worker]`` section). Creates either level if missing. Preservescomments, sibling keys, and the optional BOM.++ Renamed from ``_patch_sub_jarvis_provider_toml`` in the 2026-06-29+ Jarvis-Agents rename. Writes to ``[brain.worker]`` so new config files+ use the new section name; old ``[brain.sub_jarvis]`` blocks are still+ read via BrainConfig.worker's AliasChoices back-compat alias."""path = _ensure_writable_config_path(path)@@ -1103,10 +1127,10 @@ def _patch_sub_jarvis_provider_toml(path: Path, name: str) -> None:if brain is None:brain = tomlkit.table()doc["brain"] = brain- sub = brain.get("sub_jarvis")+ sub = brain.get("worker")if sub is None:sub = tomlkit.table()- brain["sub_jarvis"] = sub+ brain["worker"] = subsub["provider"] = nameout = tomlkit.dumps(doc)@@ -1115,13 +1139,16 @@ def _patch_sub_jarvis_provider_toml(path: Path, name: str) -> None:_atomic_write(path, out)-def _patch_sub_jarvis_key_toml(path: Path, key: str, value: object) -> None:- """Set one key under the nested ``[brain.sub_jarvis]`` table.+def _patch_worker_key_toml(path: Path, key: str, value: object) -> None:+ """Set one key under the nested ``[brain.worker]`` table.- Generalised sibling of :func:`_patch_sub_jarvis_provider_toml` (kept- untouched for parallel-session safety): walks ``brain`` -> ``sub_jarvis``+ Generalised sibling of :func:`_patch_worker_provider_toml` (kept+ untouched for parallel-session safety): walks ``brain`` -> ``worker``(creating either level if missing), preserves comments, sibling keys, andthe optional BOM.++ Renamed from ``_patch_sub_jarvis_key_toml`` in the 2026-06-29+ Jarvis-Agents rename."""path = _ensure_writable_config_path(path)@@ -1136,10 +1163,10 @@ def _patch_sub_jarvis_key_toml(path: Path, key: str, value: object) -> None:if brain is None:brain = tomlkit.table()doc["brain"] = brain- sub = brain.get("sub_jarvis")+ sub = brain.get("worker")if sub is None:sub = tomlkit.table()- brain["sub_jarvis"] = sub+ brain["worker"] = subsub[key] = valueout = tomlkit.dumps(doc)@@ -1280,44 +1307,50 @@ def _sync_brain_primary_drift_soll(name: str) -> None:log.warning("Could not sync %s to the User environment: %s", _BRAIN_PRIMARY_ENV, exc)-def _sync_sub_jarvis_provider_drift_soll(name: str) -> None:- """Best-effort sync of ``brain.sub_jarvis.provider`` into config-soll + ENV.+def _sync_worker_provider_drift_soll(name: str) -> None:+ """Best-effort sync of ``brain.worker.provider`` into config-soll + ENV.NEVER raises and NEVER breaks the (already-completed) TOML write. Sametwo-step shape as :func:`_sync_brain_primary_drift_soll`.++ Renamed from ``_sync_sub_jarvis_provider_drift_soll`` in the 2026-06-29+ Jarvis-Agents rename."""try:- _update_config_soll_sub_jarvis_provider(name)+ _update_config_soll_worker_provider(name)except Exception as exc: # noqa: BLE001 — best-effort, must not propagate- log.warning("Could not sync sub_jarvis provider to config-soll.json: %s", exc)+ log.warning("Could not sync worker provider to config-soll.json: %s", exc)try:- _set_user_env_var(_SUB_JARVIS_PROVIDER_ENV, name)+ _set_user_env_var(_WORKER_PROVIDER_ENV, name)except Exception as exc: # noqa: BLE001 — best-effort, must not propagatelog.warning("Could not sync %s to the User environment: %s",- _SUB_JARVIS_PROVIDER_ENV,+ _WORKER_PROVIDER_ENV,exc,)-def _sync_sub_jarvis_model_drift_soll(model: str) -> None:- """Best-effort sync of ``brain.sub_jarvis.model`` into config-soll + ENV.+def _sync_worker_model_drift_soll(model: str) -> None:+ """Best-effort sync of ``brain.worker.model`` into config-soll + ENV.NEVER raises and NEVER breaks the (already-completed) TOML write. Same- two-step shape as :func:`_sync_sub_jarvis_provider_drift_soll`.+ two-step shape as :func:`_sync_worker_provider_drift_soll`.++ Renamed from ``_sync_sub_jarvis_model_drift_soll`` in the 2026-06-29+ Jarvis-Agents rename."""try:- _update_config_soll_sub_jarvis_key("model", model)+ _update_config_soll_worker_key("model", model)except Exception as exc: # noqa: BLE001 — best-effort, must not propagate- log.warning("Could not sync sub_jarvis model to config-soll.json: %s", exc)+ log.warning("Could not sync worker model to config-soll.json: %s", exc)try:- _set_user_env_var(_SUB_JARVIS_MODEL_ENV, model)+ _set_user_env_var(_WORKER_MODEL_ENV, model)except Exception as exc: # noqa: BLE001 — best-effort, must not propagatelog.warning("Could not sync %s to the User environment: %s",- _SUB_JARVIS_MODEL_ENV,+ _WORKER_MODEL_ENV,exc,)@@ -1450,15 +1483,17 @@ def _update_config_soll_brain_primary(name: str) -> None:_atomic_write_text(soll_path, out)-def _update_config_soll_sub_jarvis_provider(name: str) -> None:- """Atomically set ``data["brain.sub_jarvis"]["provider"] = name`` in+def _update_config_soll_worker_provider(name: str) -> None:+ """Atomically set ``data["brain.worker"]["provider"] = name`` inconfig-soll.json.- Note the FLAT dotted key ``"brain.sub_jarvis"`` — that is how the- drift-guard soll file stores the sub-table (see scripts/config-soll.json),- NOT a nested ``data["brain"]["sub_jarvis"]``. Preserves all other keys- (``_comment``, the fallback chain, other tables). Graceful no-op when the- file is absent.+ Note the FLAT dotted key ``"brain.worker"`` — that is how the drift-guard+ soll file stores the sub-table (see scripts/config-soll.json), NOT a nested+ ``data["brain"]["worker"]``. Preserves all other keys (``_comment``, the+ fallback chain, other tables). Graceful no-op when the file is absent.++ Renamed from ``_update_config_soll_sub_jarvis_provider`` in the 2026-06-29+ Jarvis-Agents rename; now writes to the ``"brain.worker"`` flat key."""soll_path = _config_soll_path()if not soll_path.exists():@@ -1468,10 +1503,10 @@ def _update_config_soll_sub_jarvis_provider(name: str) -> None:with _WRITE_LOCK:raw = soll_path.read_text(encoding="utf-8")data = json.loads(raw)- block = data.get("brain.sub_jarvis")+ block = data.get("brain.worker")if not isinstance(block, dict):block = {}- data["brain.sub_jarvis"] = block+ data["brain.worker"] = blockif block.get("provider") == name:return # already in sync — avoid a needless rewriteblock["provider"] = name@@ -1480,13 +1515,15 @@ def _update_config_soll_sub_jarvis_provider(name: str) -> None:_atomic_write_text(soll_path, out)-def _update_config_soll_sub_jarvis_key(key: str, value: str) -> None:- """Atomically set ``data["brain.sub_jarvis"][key] = value`` in- config-soll.json.+def _update_config_soll_worker_key(key: str, value: str) -> None:+ """Atomically set ``data["brain.worker"][key] = value`` in config-soll.json.- Generalised sibling of :func:`_update_config_soll_sub_jarvis_provider`+ Generalised sibling of :func:`_update_config_soll_worker_provider`(same FLAT dotted-key layout, same preservation guarantees, same gracefulno-op when the file is absent).++ Renamed from ``_update_config_soll_sub_jarvis_key`` in the 2026-06-29+ Jarvis-Agents rename."""soll_path = _config_soll_path()if not soll_path.exists():@@ -1496,10 +1533,10 @@ def _update_config_soll_sub_jarvis_key(key: str, value: str) -> None:with _WRITE_LOCK:raw = soll_path.read_text(encoding="utf-8")data = json.loads(raw)- block = data.get("brain.sub_jarvis")+ block = data.get("brain.worker")if not isinstance(block, dict):block = {}- data["brain.sub_jarvis"] = block+ data["brain.worker"] = blockif block.get(key) == value:return # already in sync — avoid a needless rewriteblock[key] = valuediff --git a/jarvis/missions/init.py b/jarvis/missions/init.pyindex 68cf52d687..0f33070588 100644--- a/jarvis/missions/init.py+++ b/jarvis/missions/init.py@@ -286,13 +286,13 @@ def _live_subagent_provider(boot_snapshot: str | None) -> str | None:passcfg = load_config()- sub_cfg = getattr(cfg.brain, "sub_jarvis", None)+ sub_cfg = getattr(cfg.brain, "worker", None)raw = getattr(sub_cfg, "provider", None) if sub_cfg is not None else Noneif raw:resolved = str(raw).strip().lower()if resolved:return resolved- # B6 (open-source AP-22): no explicit [brain.sub_jarvis].provider → run the+ # B6 (open-source AP-22): no explicit [brain.worker].provider → run the# heavy worker on the user's ACTIVE brain provider, not the legacy Claude# CLI. A fresh openrouter/gemini/codex install never sets sub_jarvis, so# without this the default ClaudeDirectWorker spawns the absent `claude`@@ -472,10 +472,10 @@ async def bootstrap_missions(or getattr(provider_cfg, "model", None)or brain_deep_model)- # [brain.sub_jarvis] is the SOURCE OF TRUTH for the OpenClaw worker+ # [brain.worker] is the SOURCE OF TRUTH for the Jarvis-Agent worker# selection (post-Welle-4). If present and provider is set, every- # mission step routes to SubJarvisWorker — regardless of brain.primary.- sub_cfg = getattr(cfg.brain, "sub_jarvis", None)+ # mission step routes to the worker — regardless of brain.primary.+ sub_cfg = getattr(cfg.brain, "worker", None)if sub_cfg is not None:raw_provider = getattr(sub_cfg, "provider", None)if raw_provider:diff --git a/jarvis/missions/isolation/worktree.py b/jarvis/missions/isolation/worktree.pyindex 2a0c639ad5..7d833367d2 100644--- a/jarvis/missions/isolation/worktree.py+++ b/jarvis/missions/isolation/worktree.py@@ -86,6 +86,22 @@ def _slugify(value: str) -> str:return out or "x"+def resolve_outputs_root(repo_root: Path) -> Path:+ """Return the mission outputs root directory.++ Prefers ``<repo_root>.parent/jarvis-agent-outputs/`` (post-rename, 2026-06-29).+ Falls back to ``<repo_root>.parent/sub-agents-outputs/`` when that old directory+ exists AND the new one does NOT — this keeps existing missions readable without+ any migration step. Does NOT create the directory; callers are responsible.+ """+ parent = repo_root.resolve().parent+ new_dir = parent / "jarvis-agent-outputs"+ old_dir = parent / "sub-agents-outputs"+ if not new_dir.exists() and old_dir.exists():+ return old_dir # back-compat: keep existing missions accessible+ return new_dir++class WorktreeManager:"""Manages `git worktree add/remove` for Phase-6 worker tasks.@@ -110,7 +126,7 @@ class WorktreeManager:self._outputs_root = (outputs_root.resolve()if outputs_root is not None- else (self._repo_root.parent / "sub-agents-outputs").resolve()+ else resolve_outputs_root(self._repo_root))# --- Public API ---------------------------------------------------------diff --git a/jarvis/missions/workers/api_agent_worker.py b/jarvis/missions/workers/api_agent_worker.pyindex 2f261c90f0..c385af79eb 100644--- a/jarvis/missions/workers/api_agent_worker.py+++ b/jarvis/missions/workers/api_agent_worker.py@@ -95,7 +95,7 @@ def _resolve_worker_model(provider: str, explicit: str) -> str:from jarvis.core import config as _cfgroot = _cfg.load_config()- sub = getattr(root.brain, "sub_jarvis", None)+ sub = getattr(root.brain, "worker", None)if (sub is not Noneand (getattr(sub, "provider", "") or "").strip().lower() == provdiff --git a/jarvis/missions/workers/provider_chain.py b/jarvis/missions/workers/provider_chain.pyindex ae94ff78ea..a69ffcff0e 100644--- a/jarvis/missions/workers/provider_chain.py+++ b/jarvis/missions/workers/provider_chain.py@@ -243,7 +243,7 @@ def _resolve_provider_chain(from jarvis.core.config import load_configcfg = load_config()- sub_cfg = getattr(cfg.brain, "sub_jarvis", None)+ sub_cfg = getattr(cfg.brain, "worker", None)if sub_cfg is not None:primary_provider = primary_provider or getattr(sub_cfg, "provider", None)# Welle 7 (2026-05-20): "openclaw-claude" is a jarvis-side