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(missions): tighten the no-tool-endpoints error match to OpenRouter's actual copy

Ruben Lütke53ab1154a644
diff --git a/jarvis/missions/workers/api_agent_worker.py b/jarvis/missions/workers/api_agent_worker.py
index ab00aaea5b..9c94eecaec 100644
--- a/jarvis/missions/workers/api_agent_worker.py
+++ b/jarvis/missions/workers/api_agent_worker.py
@@ -283,13 +283,21 @@ class ApiAgentWorker:
# The capability pre-gate (above) catches a model the brain
# ALREADY knows is tool-incapable. Some providers (OpenRouter
# routing to a tool-less upstream) only discover this on the
- # FIRST live round-trip, surfacing as a 404 "no endpoints
+ # FIRST live round-trip, surfacing as a 404 "No endpoints
# found that support tool use"-class error. Recognize that
# shape on turn 0 and convert it to the SAME honest message
# instead of letting the raw provider error propagate up as
- # an inscrutable worker failure.
+ # an inscrutable worker failure. Matched tightly against
+ # OpenRouter's actual copy so an unrelated turn-0 error that
+ # merely mentions tools + support (e.g. "too many tools
+ # defined, exceeds support limit") is NOT mislabeled.
low = str(exc).lower()
- if turn == 0 and "tool" in low and ("support" in low or "404" in low):
+ no_tool_endpoints = (
+ ("no endpoints" in low and "tool" in low)
+ or "support tool use" in low
+ or ("404" in low and "tool" in low)
+ )
+ if turn == 0 and no_tool_endpoints:
res = ClaudeResult(
subtype="error_during_execution", is_error=True,
session_id=session_id,
diff --git a/tests/missions/test_api_agent_worker_capability_gate.py b/tests/missions/test_api_agent_worker_capability_gate.py
index 8ff2594fc6..7359d1082f 100644
--- a/tests/missions/test_api_agent_worker_capability_gate.py
+++ b/tests/missions/test_api_agent_worker_capability_gate.py
@@ -70,6 +70,21 @@ class _NoEndpointsBrain:
yield # pragma: no cover
+class _UnrelatedToolErrorBrain:
+ """A turn-0 provider error that mentions tools + support but is NOT the
+ 'no endpoints support tool use' capability error — the wrap must let it
+ propagate to the generic handler, not mislabel it as tool-incapable."""
+
+ def can_call_tools(self) -> bool:
+ return True
+
+ async def complete(self, req: BrainRequest) -> AsyncIterator[BrainDelta]:
+ raise RuntimeError(
+ "Request rejected: too many tools defined, exceeds support limit of 128"
+ )
+ yield # pragma: no cover
+
+
def _patch_brain(monkeypatch: pytest.MonkeyPatch, brain: object) -> None:
import jarvis.missions.workers.api_agent_worker as mod
@@ -143,3 +158,24 @@ async def test_first_round_trip_no_endpoints_error_is_translated(
msg = (errors[-1].result or "").lower()
assert "cannot call tools" in msg
assert "jarvis-agents" in msg
+
+
+async def test_unrelated_tool_error_is_not_mislabeled(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
+) -> None:
+ """Negative guard for the match tightening: a turn-0 error mentioning
+ 'tools' and 'support' that is NOT OpenRouter's no-tool-endpoints copy must
+ take the generic error path — no 'cannot call tools' preamble."""
+ _patch_brain(monkeypatch, _UnrelatedToolErrorBrain())
+ worker = ApiAgentWorker("openrouter")
+ events = await _drain(
+ worker, prompt="build x", worktree=tmp_path, env={}, job=None,
+ worker_id="m::0", log_dir=tmp_path / "_logs",
+ )
+
+ errors = [e for e in events if getattr(e, "is_error", False)]
+ assert errors, "expected an error result from the generic handler"
+ msg = (errors[-1].result or "").lower()
+ assert "cannot call tools" not in msg
+ # the raw provider text still reaches the user via the generic handler
+ assert "too many tools defined" in msg