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(local-models): the assistant's turn carries only its own tools and web search — the router's full set broke Gemini's schema validation

rubenluetke10-beeped9a6659b608
diff --git a/jarvis/agent_chat/runner_brain.py b/jarvis/agent_chat/runner_brain.py
index 2010fcb04f..450941fcaa 100644
--- a/jarvis/agent_chat/runner_brain.py
+++ b/jarvis/agent_chat/runner_brain.py
@@ -158,7 +158,9 @@ def build_override(
tools_extra=(
dict(kit_tools) if kit_tools is not None else folder_tools(cwd, stance=stance)
),
- tool_filter=plan_filter if stance == PLAN_STANCE else None,
+ tool_filter=_compose_filters(
+ kit.tool_filter, plan_filter if stance == PLAN_STANCE else None
+ ),
credential_scope=kit.credential_scope,
system_extra=system_extra,
tool_context={
@@ -175,6 +177,22 @@ def build_override(
)
+def _compose_filters(
+ *filters: Callable[[dict[str, Tool]], dict[str, Tool]] | None,
+) -> Callable[[dict[str, Tool]], dict[str, Tool]] | None:
+ """The kit's filter first, then the stance's; ``None`` when neither applies."""
+ active = [f for f in filters if f is not None]
+ if not active:
+ return None
+
+ def _apply(tools: dict[str, Tool]) -> dict[str, Tool]:
+ for f in active:
+ tools = f(tools)
+ return tools
+
+ return _apply
+
+
async def kit_payload(session: AgentChatSession, brain: Any) -> tuple[dict[str, Tool] | None, str]:
"""The surface kit's per-turn hands and briefing: ``(tools, system_extra)``.
diff --git a/jarvis/agent_chat/surface_kits.py b/jarvis/agent_chat/surface_kits.py
index 126b116c21..4ebdde1f36 100644
--- a/jarvis/agent_chat/surface_kits.py
+++ b/jarvis/agent_chat/surface_kits.py
@@ -80,6 +80,10 @@ class SurfaceKit:
tool_origin: str = "agent-chat"
credential_scope: str = "agent"
max_turns: int | None = None
+ #: Applied to the merged tool set (the brain's own plus ``tools``): a
+ #: surface that only ever needs its own hands keeps the request small
+ #: and free of foreign schemas a provider may refuse. ``None`` = all.
+ tool_filter: Callable[[dict[str, Tool]], dict[str, Tool]] | None = None
# ── local-models builders ─────────────────────────────────────────────────
@@ -147,6 +151,20 @@ async def _local_models_extra(cfg: Any, brain: Any) -> str:
)
+def _local_models_filter(tools: dict[str, Tool]) -> dict[str, Tool]:
+ """Only the assistant's own hands and web search.
+
+ The router's full surface is 100+ declarations, some with schema shapes
+ (``oneOf``) the Gemini SDK rejects outright — one such tool failed every
+ turn of this surface on 2026-08-25. The assistant never needs them.
+ """
+ return {
+ name: tool
+ for name, tool in tools.items()
+ if name.startswith("lm_") or name in ("search_web", "search-web")
+ }
+
+
# ── the table ─────────────────────────────────────────────────────────────
_KITS: Final[dict[str, SurfaceKit]] = {
@@ -166,6 +184,7 @@ _KITS: Final[dict[str, SurfaceKit]] = {
tools=_local_models_tools,
system_extra=_local_models_extra,
tool_origin=LOCAL_MODELS_TOOL_ORIGIN,
+ tool_filter=_local_models_filter,
# A guided run pulls, sets five roles, tunes and tests: more tool
# rounds than a chat answer needs.
max_turns=40,
diff --git a/tests/unit/agent_chat/test_surface_kits.py b/tests/unit/agent_chat/test_surface_kits.py
index 64e8d75490..3a53ee22c8 100644
--- a/tests/unit/agent_chat/test_surface_kits.py
+++ b/tests/unit/agent_chat/test_surface_kits.py
@@ -128,3 +128,18 @@ def test_local_models_surface_drives_cli_seats_through_the_brain() -> None:
assert resolve_runner("gemini", surface="local-models") == "brain"
# The Jarvis surface keeps the vendor CLI for a subscription seat.
assert resolve_runner("antigravity", surface="jarvis") != "brain"
+
+
+def test_local_models_surface_keeps_only_its_own_hands_and_web_search() -> None:
+ """The router's 100+ declarations (some with schemas Gemini refuses) never
+ reach this surface: only lm_* and web search survive the kit filter."""
+ from jarvis.agent_chat.surface_kits import kit_for
+
+ class _T:
+ def __init__(self, name: str) -> None:
+ self.name = name
+
+ tools = {n: _T(n) for n in ("lm_hardware", "search_web", "patch", "spawn-worker", "lm_pull")}
+ kept = kit_for("local-models").tool_filter(tools) # type: ignore[misc]
+ assert sorted(kept) == ["lm_hardware", "lm_pull", "search_web"]
+ assert kit_for("jarvis").tool_filter is None