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(brain): raise the UltraWiki injection budget to 400ms and make it a knob

Ruben Lütke2d60115bf202
diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.py
index af105ed759..a1f9983d68 100644
--- a/jarvis/brain/factory.py
+++ b/jarvis/brain/factory.py
@@ -1353,6 +1353,10 @@ def _phase2_full_brain(
# fallback only (see _resolve_wiki_vault_root).
vault_path = _resolve_wiki_vault_root(config)
search = VaultSearch(vault_path)
+ from jarvis.brain.wiki_context import ( # noqa: PLC0415 — sibling import, kept local like the class import above
+ DEFAULT_ULTRA_LATENCY_BUDGET_MS,
+ )
+
manager._wiki_injector = WikiContextInjector(
search=search,
max_chars=getattr(wiki_cfg, "max_chars", 1500),
@@ -1363,6 +1367,13 @@ def _phase2_full_brain(
min_relative_score=float(
getattr(wiki_cfg, "min_relative_score", 0.35)
),
+ ultra_latency_budget_ms=int(
+ getattr(
+ wiki_cfg,
+ "ultra_latency_budget_ms",
+ DEFAULT_ULTRA_LATENCY_BUDGET_MS,
+ )
+ ),
)
log.info(
"WikiContextInjector active (vault=%s, budget=%dms, gate=%s)",
diff --git a/jarvis/brain/wiki_context.py b/jarvis/brain/wiki_context.py
index c0b1903cc6..b24c410b85 100644
--- a/jarvis/brain/wiki_context.py
+++ b/jarvis/brain/wiki_context.py
@@ -150,7 +150,13 @@ _TOKEN_RE = re.compile(r"[^\w\s]|\s+", re.UNICODE)
#: store query (plus a possible query embedding) rather than the vault's grep;
#: design doc 03 allots <= 150 ms to the fan-out inside a <= 900 ms
#: to-first-spoken-token budget, and this stays in that order of magnitude.
-DEFAULT_ULTRA_LATENCY_BUDGET_MS = 250
+#: 400 (was 250) after the 2026-07-26 19:45 live trace: the legs finished at
+#: 209 ms but event-loop pressure from a background sync burned the remainder
+#: and the whole context was dropped at exactly 250 — a busted budget costs a
+#: multi-second tool round trip, so a modest allowance for load is the
+#: cheaper side of that trade. Configurable via
+#: ``[wiki_integration].ultra_latency_budget_ms``.
+DEFAULT_ULTRA_LATENCY_BUDGET_MS = 400
#: How many UltraWiki candidates the gates get to judge. Small on purpose: the
#: block is capped at ``max_chars`` anyway and every extra candidate is one more