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(plugins): honor explicit marketplace tool requests over CLI preference

rubenluetke10-beepf4266130ac90
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index fac268bdcf..7b7943269b 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -7089,13 +7089,13 @@ class BrainManager:
return tools
def _suppress_plugins_covered_by_cli(
- self, tools: dict[str, Tool]
+ self, tools: dict[str, Tool], user_text: str = ""
) -> dict[str, Tool]:
"""Hide plugin/native tools whose CLI counterpart is connected (req 4).
A CLI runs a local subprocess and is cheaper than a plugin's MCP/API
hop, so when a CLI for a service is active its plugin is removed from the
- turn's tool surface (fallback only). Defensive: returns the tools
+ turn's tool surface unless explicitly requested. Defensive: returns the tools
unchanged on any fault (never blind the brain on the voice path).
"""
try:
@@ -7103,7 +7103,7 @@ class BrainManager:
suppress_plugin_tools_covered_by_cli,
)
- return suppress_plugin_tools_covered_by_cli(tools)
+ return suppress_plugin_tools_covered_by_cli(tools, user_text)
except Exception: # noqa: BLE001
log.debug("plugin-CLI suppression failed; full tool set", exc_info=True)
return tools
@@ -11899,7 +11899,7 @@ class BrainManager:
# utterance (progressive disclosure), then hide any plugin whose
# CLI counterpart is connected (req 4: CLI > plugin fallback).
else self._suppress_plugins_covered_by_cli(
- self._apply_plugin_relevance(routing_text, self._tools)
+ self._apply_plugin_relevance(routing_text, self._tools), routing_text
)
)
# Skill inline-injected (AD-S4): drop run-skill so a weak model
diff --git a/jarvis/clis/capability_provider.py b/jarvis/clis/capability_provider.py
index 2fad595426..706dcd64dd 100644
--- a/jarvis/clis/capability_provider.py
+++ b/jarvis/clis/capability_provider.py
@@ -10,6 +10,7 @@ must never propagate into the caller (registry lifecycle or voice path).
from __future__ import annotations
import logging
+import re
from collections.abc import Mapping, Sequence
from typing import Any
@@ -186,17 +187,49 @@ PLUGIN_CLI_OVERLAP: dict[str, str] = {
}
-def suppress_plugin_tools_covered_by_cli(tools: dict[str, Any]) -> dict[str, Any]:
+def _explicit_plugin_request(
+ user_text: str, plugin_id: str, tools: Mapping[str, Any]
+) -> bool:
+ """Recognize a named plugin/MCP vehicle, not a generic service request."""
+ name = re.escape(plugin_id)
+ # A URL or source path mentioning a service is not a vehicle request.
+ start = r"(?<![\w/\\:.-])"
+ boundary = rf"{start}{name}"
+ vehicle = r"(?:marketplace[\s-]+)?(?:plugin|mcp)(?:[\s-]+tool)?"
+ for tool_name in tools:
+ if tool_name.startswith(f"{plugin_id}/") and re.search(
+ rf"{start}{re.escape(tool_name)}(?![\w/\\-]|\.\w)",
+ user_text,
+ re.IGNORECASE,
+ ):
+ return True
+ return bool(
+ re.search(
+ rf"{boundary}[\s-]+{vehicle}\b|"
+ rf"\b{vehicle}[\s:-]+{name}(?![\w-])",
+ user_text,
+ re.IGNORECASE,
+ )
+ )
+
+
+def suppress_plugin_tools_covered_by_cli(
+ tools: dict[str, Any], user_text: str = ""
+) -> dict[str, Any]:
"""Drop plugin/native tools whose CLI counterpart is connected this turn.
For each overlap entry whose ``cli_<name>`` is present in ``tools``, removes
the namespaced ``<plugin_id>/*`` tools and the exact native ``<plugin_id>``
- tool. Defensive: returns ``tools`` unchanged on any fault.
+ tool, unless the user explicitly names that plugin/MCP vehicle or its tool
+ namespace. Generic service requests keep CLI precedence. Defensive: returns
+ ``tools`` unchanged on any fault.
"""
try:
present_clis = {n for n in tools if n.startswith(TOOL_NAME_PREFIX)}
drop: set[str] = set()
for plugin_id, cli_name in PLUGIN_CLI_OVERLAP.items():
+ if _explicit_plugin_request(user_text, plugin_id, tools):
+ continue
if f"{TOOL_NAME_PREFIX}{cli_name}" not in present_clis:
continue
prefix = f"{plugin_id}/"
diff --git a/tests/unit/brain/test_plugin_cli_suppression_wiring.py b/tests/unit/brain/test_plugin_cli_suppression_wiring.py
index 8410d49566..44591ccdbd 100644
--- a/tests/unit/brain/test_plugin_cli_suppression_wiring.py
+++ b/tests/unit/brain/test_plugin_cli_suppression_wiring.py
@@ -27,3 +27,14 @@ def test_method_keeps_plugin_when_cli_absent():
mgr = _mgr()
tools = {"github/list_prs": SimpleNamespace(name="github/list_prs")}
assert mgr._suppress_plugins_covered_by_cli(tools) == tools
+
+
+def test_method_keeps_explicit_plugin_request_when_cli_present():
+ mgr = _mgr()
+ tools = {
+ "cli_gh": SimpleNamespace(name="cli_gh"),
+ "github/get_me": SimpleNamespace(name="github/get_me"),
+ }
+ assert mgr._suppress_plugins_covered_by_cli(
+ tools, "Use github/get_me through the GitHub plugin."
+ ) == tools
diff --git a/tests/unit/clis/test_capability_provider.py b/tests/unit/clis/test_capability_provider.py
index fb2a74be0b..0951e8f48e 100644
--- a/tests/unit/clis/test_capability_provider.py
+++ b/tests/unit/clis/test_capability_provider.py
@@ -1,6 +1,8 @@
"""Capability provider: CliSpec.capabilities -> CapabilityRegistry (AD-CLI1..3)."""
from dataclasses import replace
+import pytest
+
from jarvis.clis.capability_provider import (
DOMAIN_VOCAB,
PLUGIN_CLI_OVERLAP,
@@ -260,5 +262,52 @@ def test_suppress_defensive_on_bad_input():
assert suppress_plugin_tools_covered_by_cli(None) is None # type: ignore[arg-type]
[email protected]("plugin_id,cli_name", PLUGIN_CLI_OVERLAP.items())
+ "user_text",
+ [
+ "Use {plugin}/get_me",
+ "Use `{plugin}/get_me`.",
+ "Use '{plugin}/get_me'.",
+ "Use the {plugin} plugin",
+ "Use MCP: {plugin}",
+ ],
+)
+def test_explicit_plugin_vehicle_survives_cli_precedence(plugin_id, cli_name, user_text):
+ plugin_tool = f"{plugin_id}/get_me"
+ tools = {
+ f"cli_{cli_name}": FakeTool(f"cli_{cli_name}"),
+ plugin_tool: FakeTool(plugin_tool),
+ plugin_id: FakeTool(plugin_id),
+ }
+ assert suppress_plugin_tools_covered_by_cli(
+ tools, user_text.format(plugin=plugin_id)
+ ) == tools
+
+
+ "user_text",
+ [
+ "Show my GitHub profile",
+ "Use the Stripe plugin and show GitHub issues",
+ "Use notgithub/get_me",
+ "Use github-tools/get_me",
+ "Review https://example.test/github/project",
+ "Fix src/github/client.py using gh",
+ "Review https://example.test/github/get_me",
+ "Fix src/github/get_me using gh",
+ "Fix github/get_me.py using gh",
+ "Fix github/client.py using gh",
+ r"Fix src\github/get_me using gh",
+ ],
+)
+def test_generic_or_other_vehicle_request_keeps_cli_precedence(user_text):
+ tools = {
+ "cli_gh": FakeTool("cli_gh"),
+ "github/get_me": FakeTool("github/get_me"),
+ }
+ assert set(suppress_plugin_tools_covered_by_cli(tools, user_text)) == {"cli_gh"}
+
+
def test_overlap_map_is_nonempty_dict():
assert isinstance(PLUGIN_CLI_OVERLAP, dict) and PLUGIN_CLI_OVERLAP