fix(doctor): image_gen reports "no provider configured", not "system dependency not met"

image_gen has several setup paths (FAL_KEY, managed Nous image generation,
plugin providers) so it declares no single `requires_env`; doctor's generic
branch then labelled a missing credential a "system dependency not met" and
left it out of the "run hermes setup" summary.

A small per-toolset setup-hint table: image_gen gets an actionable line
pointing at `hermes tools`, counts toward the setup summary, and toolsets
with a genuine system dependency (homeassistant) keep the old wording.

Port of PR #9548 by @skyc1e onto `hermes_cli/doctor_tools.py`.

Fixes #9516
This commit is contained in:
skyc1e
2026-07-12 14:21:19 +00:00
committed by Teknium
parent 1dce69be4e
commit 7d25ae58a7
2 changed files with 41 additions and 3 deletions
+16 -3
View File
@@ -115,9 +115,21 @@ def _enabled_cli_toolsets_for_doctor() -> set[str] | None:
return None
# Toolsets gated by a multi-path setup (several providers / managed auth) declare no single
# `requires_env`, so the generic branch would call a missing credential a "system dependency".
# Name the real fix instead (#9516).
_TOOLSET_SETUP_HINTS: dict[str, str] = {
"image_gen": "(no image generation provider configured — set one up with 'hermes tools')",
}
def _setup_gated(item: dict) -> bool:
return bool(item.get("missing_vars") or item.get("env_vars") or item.get("name") in _TOOLSET_SETUP_HINTS)
def _missing_api_key_toolsets_for_summary(unavailable: list[dict]) -> list[dict]:
"""Filter unavailable API-key toolsets to those enabled for the CLI."""
api_key_unavailable = [item for item in unavailable if item.get("missing_vars") or item.get("env_vars")]
"""Filter unavailable setup-gated toolsets (missing key OR setup hint) to those enabled for the CLI."""
api_key_unavailable = [item for item in unavailable if _setup_gated(item)]
enabled_toolsets = _enabled_cli_toolsets_for_doctor()
return api_key_unavailable if enabled_toolsets is None else [i for i in api_key_unavailable if str(i.get("name") or "") in enabled_toolsets]
@@ -445,7 +457,8 @@ def _check_tool_availability(should_fix: bool, f: Finding) -> None:
(check_ok if status == "ok" else check_warn)(label, detail)
for item in unavailable:
env_vars = item.get("missing_vars") or item.get("env_vars") or []
check_warn(item["name"], f"(missing {', '.join(env_vars)})" if env_vars else "(system dependency not met)")
detail = f"(missing {', '.join(env_vars)})" if env_vars else _TOOLSET_SETUP_HINTS.get(item["name"], "(system dependency not met)")
check_warn(item["name"], detail)
# Only toolsets enabled for the CLI count toward the summary; default-off or
# disabled toolsets may warn above but must not pollute it.
api_disabled = _missing_api_key_toolsets_for_summary(unavailable)
+25
View File
@@ -89,6 +89,31 @@ class TestDoctorToolAvailabilitySummary:
assert [item["name"] for item in filtered] == ["web"]
def test_image_gen_without_provider_reports_setup_hint_not_system_dependency(self, monkeypatch):
"""image_gen declares no single env var (FAL / managed Nous / plugin providers); an
unconfigured backend is a setup problem and must say so, and it counts toward the
'run hermes setup' summary like any missing key (#9516)."""
unavailable = [{"name": "image_gen", "env_vars": [], "tools": ["image_generate"]},
{"name": "homeassistant", "env_vars": [], "tools": []}]
monkeypatch.setattr(doctor_tools, "_enabled_cli_toolsets_for_doctor", lambda: {"image_gen"})
monkeypatch.setattr(doctor_tools, "_apply_doctor_tool_availability_overrides", lambda a, u: (a, u))
monkeypatch.setattr(doctor_tools, "_doctor_web_capability_rows", lambda: [])
fake_model_tools = types.SimpleNamespace(
check_tool_availability=lambda: ([], unavailable),
TOOLSET_REQUIREMENTS={"image_gen": {"name": "image_gen"}, "homeassistant": {"name": "homeassistant"}},
)
monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools)
buf = io.StringIO()
with contextlib.redirect_stdout(buf):
f = doctor_tools._check_tool_availability(False)
out = buf.getvalue()
image_line = next(line for line in out.splitlines() if "image_gen" in line)
assert "hermes tools" in image_line and "system dependency" not in image_line
assert "system dependency not met" in next(line for line in out.splitlines() if "homeassistant" in line)
assert any("hermes setup" in issue for issue in f.issues)
def test_web_capability_rows_warn_when_selected_provider_not_ready(self, monkeypatch):
"""#78412: selected firecrawl with is_available=False must warn."""
class _Unavailable: