Skip to content

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.

fix(agentic-ide): let the coding subscription write recaps when every API key is dead

rubenluetke10-beepcff5476a7f5c
diff --git a/jarvis/agentic_ide/recap_engine.py b/jarvis/agentic_ide/recap_engine.py
index ffc93f3794..82d7f4d24b 100644
--- a/jarvis/agentic_ide/recap_engine.py
+++ b/jarvis/agentic_ide/recap_engine.py
@@ -112,11 +112,12 @@ CALL_TIMEOUT_S = 45.0
#: failed, and whatever they burned must still leave the CLI a real chance.
SUBSCRIPTION_CLI_TIMEOUT_S = 35.0
-#: How many provider FAMILIES a single summary may try before giving up. A
+#: How many API provider FAMILIES a single summary may try before giving up. A
#: depleted key fails at call time, after instantiating fine — the next try
#: must come from a different family (AP-22), and two spare families cover
#: every install that has anything to cross to without turning one recap into
-#: a tour of every configured provider.
+#: a tour of every configured provider. A connected coding subscription rides
+#: BEHIND this cap as the true last resort; it never competes for these slots.
MAX_PROVIDER_TRIES = 3
#: After this many consecutive failures a pane stops asking for a while. A
@@ -616,10 +617,17 @@ def _resolve_brains() -> list[Any]:
# CLI running in the panes. It goes LAST because a CLI call costs a process
# spawn and seconds where an API call costs milliseconds — it should write
# the recap only when everything cheaper is dead.
- if len(candidates) < MAX_PROVIDER_TRIES:
- subscription = _resolve_subscription(config)
- if subscription is not None:
- candidates.append(subscription)
+ #
+ # Appended UNCONDITIONALLY, not into a spare slot. It used to be skipped
+ # whenever MAX_PROVIDER_TRIES API families were configured — which made it
+ # unreachable on exactly the install it was built for: three configured but
+ # broken keys occupied every slot, and the one credential provably working
+ # (the CLI running in the panes) was never asked. Resolving it here only
+ # instantiates the brain; the expensive CLI call happens solely when every
+ # API family has already failed.
+ subscription = _resolve_subscription(config)
+ if subscription is not None:
+ candidates.append(subscription)
return candidates
diff --git a/tests/unit/agentic_ide/test_recap_engine.py b/tests/unit/agentic_ide/test_recap_engine.py
index 63d860f57f..cbf0f57297 100644
--- a/tests/unit/agentic_ide/test_recap_engine.py
+++ b/tests/unit/agentic_ide/test_recap_engine.py
@@ -452,20 +452,22 @@ def test_a_connected_subscription_is_the_last_candidate(monkeypatch) -> None:
assert recap_engine._resolve_brains() == [api, subscription] # noqa: SLF001
-def test_a_full_api_chain_never_pays_for_the_cli_probe(monkeypatch) -> None:
- """The subscription is a last resort, not a fourth opinion."""
+def test_a_full_api_chain_still_ends_at_the_subscription(monkeypatch) -> None:
+ """The regression that shipped: three configured-but-dead API keys filled
+ every candidate slot, and the one credential provably working — the CLI
+ running in the panes — was never asked. The subscription rides behind the
+ API cap, always."""
from jarvis.brain import resolver
brains = [SimpleNamespace(model=f"api-{n}") for n in range(recap_engine.MAX_PROVIDER_TRIES)]
+ subscription = SimpleNamespace(model="coding-cli")
monkeypatch.setattr(resolver, "frontier_brain_candidates", lambda cfg: iter(brains))
-
- def never(cfg, **kwargs): # noqa: ANN001, ANN202
- raise AssertionError("the CLI probe must not run when the chain is full")
-
- monkeypatch.setattr(resolver, "resolve_subscription_brain", never)
+ monkeypatch.setattr(
+ resolver, "resolve_subscription_brain", lambda cfg, **kwargs: subscription
+ )
monkeypatch.setattr("jarvis.core.config.load_config", lambda: SimpleNamespace())
- assert recap_engine._resolve_brains() == brains # noqa: SLF001
+ assert recap_engine._resolve_brains() == [*brains, subscription] # noqa: SLF001
def test_a_failing_provider_leaves_the_previous_sentence_in_place() -> None: