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
fix(voice): stop scheduled skill runs from announcing provider failures out of nowhere
rubenluetke10-beepb45ea1c89704
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex f741f8f512..aa89940dc7 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -6759,7 +6759,11 @@ class BrainManager:window = int(getattr(brain, "context_window", 0) or 0)except (TypeError, ValueError):window = 0- if window <= 0:+ try:+ max_tools = int(getattr(brain, "max_tools", 0) or 0)+ except (TypeError, ValueError):+ max_tools = 0+ if window <= 0 and max_tools <= 0:return toolsused = (_approx_tokens(system_prompt)@@ -6773,17 +6777,18 @@ class BrainManager:if getattr(self, "_skill_turn_match", None) is not None:keep.add("run-skill")fitted, dropped = _fit_tools_to_context_window(- tools, context_window=window, used_tokens=used, keep=keep+ tools, context_window=window, used_tokens=used, keep=keep, max_tools=max_tools)if dropped:log.warning("Tool surface trimmed for %s: %d of %d tools hidden this turn so "- "the request fits the model's %d-token window (prompt+history "- "~%d tokens, budget for tools %d). First hidden: %s",+ "the request fits the model's %d-token window and %s-tool cap "+ "(prompt+history ~%d tokens, budget for tools %d). First hidden: %s",getattr(brain, "name", type(brain).__name__),len(dropped),len(tools),window,+ max_tools or "no",used,max(window - used, 0),", ".join(dropped[:5]),@@ -13870,13 +13875,14 @@ def _fit_tools_to_context_window(context_window: int,used_tokens: int,keep: Iterable[str] = (),+ max_tools: int = 0,) -> tuple[dict[str, Tool], list[str]]:- """Shrink a tool surface until it fits ``context_window``.+ """Shrink a tool surface until it fits ``context_window`` and ``max_tools``.- Returns ``(surviving tools, dropped names in drop order)``. A window of- ``0`` or less means the brain declared none, and the surface comes back- untouched. ``used_tokens`` is everything else the request carries (system- prompt, history, reserve); what remains is the budget for tools.+ Returns ``(surviving tools, dropped names in drop order)``. A window or a+ tool cap of ``0`` or less means the brain declared none. ``used_tokens``+ is everything else the request carries (system prompt, history,+ reserve); what remains is the budget for tools.Drop order, deliberately: connected-server tools first — they areadditions to Jarvis's own surface, each one a full JSON schema, and on a@@ -13886,12 +13892,13 @@ def _fit_tools_to_context_window(When even the prompt alone exceeds the window every droppable tool goesand the caller's log says so; the request still fails, but honestly."""- if context_window <= 0 or not tools:+ if (context_window <= 0 and max_tools <= 0) or not tools:return tools, []costs = {name: _tool_surface_tokens(name, tool) for name, tool in tools.items()}- budget = context_window - used_tokens+ budget = context_window - used_tokens if context_window > 0 else sum(costs.values())total = sum(costs.values())- if total <= budget:+ count_cap = max_tools if max_tools > 0 else len(tools)+ if total <= budget and len(tools) <= count_cap:return tools, []kept = set(keep)droppable = [name for name in tools if name not in kept]@@ -13903,10 +13910,12 @@ def _fit_tools_to_context_window())dropped: list[str] = []+ remaining = len(tools)for name in droppable:- if total <= budget:+ if total <= budget and remaining <= count_cap:breaktotal -= costs[name]+ remaining -= 1dropped.append(name)gone = set(dropped)return {name: tool for name, tool in tools.items() if name not in gone}, droppeddiff --git a/jarvis/plugins/brain/gemini.py b/jarvis/plugins/brain/gemini.pyindex e40b319346..19cd4bf639 100644--- a/jarvis/plugins/brain/gemini.py+++ b/jarvis/plugins/brain/gemini.py@@ -545,9 +545,38 @@ def _sanitize_for_gemini(schema: dict[str, Any]) -> dict[str, Any]:out[k] = _gemini_single_type(v)else:out[k] = v+ if out.get("type") == "array" and not _gemini_schema_is_typed(out.get("items")):+ out["items"] = _gemini_array_items(schema)return out+def _gemini_schema_is_typed(schema: Any) -> bool:+ return isinstance(schema, dict) and bool(+ schema.get("type") or schema.get("anyOf") or schema.get("any_of")+ )+++def _gemini_array_items(schema: dict[str, Any]) -> dict[str, Any]:+ """Element schema for an array Gemini would reject as untyped.++ Gemini requires every array to carry a typed ``items``. A tuple+ (``tuple[float, float, float]`` → ``prefixItems``, no ``items``) or a bare+ ``items: {}`` fails the WHOLE request with "items: missing field" (live+ 2026-09-29 08:00: a connected server's ``transform.scale`` took Gemini out+ of the chain). The first tuple slot is the best honest guess; otherwise a+ string, the one type every value can be written as.+ """+ for key in ("prefixItems", "prefix_items"):+ slots = schema.get(key)+ if isinstance(slots, list) and slots and isinstance(slots[0], dict):+ first = _sanitize_for_gemini(slots[0])+ if _gemini_schema_is_typed(first):+ return first+ items = schema.get("items")+ base = _sanitize_for_gemini(items) if isinstance(items, dict) else {}+ return {**base, "type": "string"}++_GEMINI_TYPE_NAMES: tuple[str, ...] = ("string","number",diff --git a/jarvis/plugins/brain/grok.py b/jarvis/plugins/brain/grok.pyindex 8f8649eeb3..399efbc303 100644--- a/jarvis/plugins/brain/grok.py+++ b/jarvis/plugins/brain/grok.py@@ -20,6 +20,10 @@ class GrokBrain:name: str = "grok"context_window: int = 1_000_000+ # xAI refuses the whole request above this many tools ("Maximum tools+ # limit reached. 378 tools have been provided but the maximum is 350",+ # live 2026-09-29); the manager trims the surface to it.+ max_tools: int = 350supports_tools: bool = True# xAI's OpenAI-compatible chat API accepts ``image_url`` data URIs on# grok-4.x. A False here made Screen Context / Computer-Use skip a livediff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex ebe8d72ea6..500305f1dd 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -399,6 +399,7 @@ _HELD_FOR_CALL_SOURCES: frozenset[str] = frozenset("workflows.runner","workflows.scheduler","desktop_app.conductor",+ "skills.cron",})@@ -4764,8 +4765,9 @@ class SpeechPipeline:The brain receives a synthetic scheduled-run turn with the skillnoted (``note_skill_trigger`` → instruction injection + SkillInvoked- source="cron"); the reply is announced via ``AnnouncementRequested``- (scrubbed TTS path). Falls back to the legacy macro runner when the+ source="cron"); the reply is queued as a held ``AnnouncementRequested``+ and spoken at the next call, and a total provider failure stays+ silent. Falls back to the legacy macro runner when thewired brain cannot take the handoff (echo/mock brains)."""from jarvis.skills.schema import SkillLifecycleState@@ -4821,14 +4823,29 @@ class SpeechPipeline:_prompts.get(lang, _prompts["en"]).format(name=skill.name))text = (reply or "").strip()+ if self._brain_turn_failed():+ # Nobody called Jarvis for this turn: a provider-chain failure on a+ # scheduled run is not news worth speaking into an idle room (live+ # 2026-09-29 08:00: the daily triage skill failed on every provider+ # and Jarvis announced "my stored API key is being rejected" out of+ # nowhere). The API-keys view shows the broken key; the log keeps+ # the chain diagnostic.+ log.warning(+ "Cron skill '%s' failed on every provider; staying silent", skill.name+ )+ returnif text and self._bus is not None:try:+ # Held for the next call like every other background result+ # (_HELD_FOR_CALL_SOURCES): a scheduled run never speaks+ # into a room where nobody called Jarvis.await self._bus.publish(AnnouncementRequested(- source_layer="speech.pipeline",+ source_layer="skills.cron",text=text,language=lang,priority="normal",+ kind=SPOKEN_KIND_COMPLETION,))except Exception as exc: # noqa: BLE001diff --git a/tests/unit/brain/test_context_window_fit.py b/tests/unit/brain/test_context_window_fit.pyindex 21f56a9556..d39edf2ce1 100644--- a/tests/unit/brain/test_context_window_fit.py+++ b/tests/unit/brain/test_context_window_fit.py@@ -248,3 +248,35 @@ class TestContextOverflowCause:assert "Kontextfenster" in text # i18n-allow: the diagnostic is Germanassert "ollama" in textassert "Netzwerk" not in text # i18n-allow+++class TestToolCountCap:+ """Live 2026-09-29: xAI refused 378 tools ("the maximum is 350")."""++ def test_count_cap_trims_without_a_window(self) -> None:+ tools = {f"t{i}": _tool(f"t{i}", mcp=i < 3) for i in range(10)}+ fitted, dropped = _fit_tools_to_context_window(+ tools, context_window=0, used_tokens=0, max_tools=7+ )+ assert len(fitted) == 7+ # Connected-server tools leave first.+ assert set(dropped) == {"t0", "t1", "t2"}++ def test_count_cap_never_drops_kept_tools(self) -> None:+ tools = {f"t{i}": _tool(f"t{i}") for i in range(5)}+ fitted, _ = _fit_tools_to_context_window(+ tools, context_window=0, used_tokens=0, keep={"t0"}, max_tools=2+ )+ assert "t0" in fitted and len(fitted) == 2++ def test_under_the_cap_is_untouched(self) -> None:+ tools = {f"t{i}": _tool(f"t{i}") for i in range(5)}+ fitted, dropped = _fit_tools_to_context_window(+ tools, context_window=0, used_tokens=0, max_tools=5+ )+ assert fitted is tools and dropped == []++ def test_grok_declares_its_cap(self) -> None:+ from jarvis.plugins.brain.grok import GrokBrain++ assert GrokBrain.max_tools == 350diff --git a/tests/unit/brain/test_gemini_schema_sanitize.py b/tests/unit/brain/test_gemini_schema_sanitize.pyindex 780dd67d49..91dcfa50a5 100644--- a/tests/unit/brain/test_gemini_schema_sanitize.py+++ b/tests/unit/brain/test_gemini_schema_sanitize.py@@ -178,3 +178,36 @@ def test_the_sanitized_schema_passes_googles_own_validator():types.Schema.model_validate(clean) # must not raise# The exclusive bound was converted, not merely dropped.assert clean["properties"]["page"]["minimum"] == 0+++def test_tuple_array_without_items_gets_typed_items():+ """Live 2026-09-29: ``transform.scale`` (a tuple → ``prefixItems``, no+ ``items``) failed the whole request with "items: missing field"."""+ bad = {+ "type": "object",+ "properties": {+ "transform": {+ "type": "object",+ "properties": {+ "scale": {+ "type": "array",+ "prefixItems": [{"type": "number"}] * 3,+ "minItems": 3,+ "maxItems": 3,+ },+ "rotation": {"type": "array", "items": {}},+ "tags": {"type": "array"},+ },+ }+ },+ }+ clean = _sanitize_for_gemini(bad)+ props = clean["properties"]["transform"]["properties"]+ assert props["scale"]["items"] == {"type": "number"}+ assert props["rotation"]["items"]["type"] == "string"+ assert props["tags"]["items"]["type"] == "string"+++def test_typed_array_items_are_left_alone():+ schema = {"type": "array", "items": {"type": "integer", "minimum": 0}}+ assert _sanitize_for_gemini(schema)["items"] == {"type": "integer", "minimum": 0}diff --git a/tests/unit/speech/test_cron_skill_language.py b/tests/unit/speech/test_cron_skill_language.pyindex 74941928d6..848b810bbb 100644--- a/tests/unit/speech/test_cron_skill_language.py+++ b/tests/unit/speech/test_cron_skill_language.py@@ -84,3 +84,27 @@ async def test_cron_skill_english_conversation_prompts_and_announces_english() -assert brain.prompt is not None and "scheduled run" in brain.prompt.lower()anns = [e for e in bus.published if isinstance(e, AnnouncementRequested)]assert anns and anns[-1].language == "en"+++async def test_cron_skill_result_is_held_for_the_next_call() -> None:+ """A scheduled run never speaks into an idle room (mandate 2026-09-28)."""+ from jarvis.speech.pipeline import _HELD_FOR_CALL_SOURCES, _READBACK_KINDS++ pipe, _brain, bus = _pipe(reply_language="auto", conversation_language="en")+ await pipe._handle_cron_skill(_skill())+ anns = [e for e in bus.published if isinstance(e, AnnouncementRequested)]+ assert anns+ assert anns[-1].source_layer in _HELD_FOR_CALL_SOURCES+ assert anns[-1].kind in _READBACK_KINDS+ assert SpeechPipeline._is_agent_reply(anns[-1])+++async def test_cron_skill_total_provider_failure_stays_silent() -> None:+ """Live 2026-09-29 08:00: the daily triage skill failed on every provider+ and Jarvis said "my stored API key is being rejected" out of nowhere."""+ pipe, brain, bus = _pipe(reply_language="auto", conversation_language="en")+ brain._last_turn_all_failed = True # type: ignore[attr-defined]+ await pipe._handle_cron_skill(_skill())+ assert not [e for e in bus.published if isinstance(e, AnnouncementRequested)]