mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(doctor): skip pluggable provider profiles when a dedicated check exists (#22346)
Problem ------- `hermes doctor` ran two health checks for Anthropic: a dedicated one with the correct `x-api-key` + `anthropic-version` headers, and a generic Bearer-auth one driven by the pluggable `ProviderProfile` for "anthropic". The generic check called `https://api.anthropic.com/v1/models` with `Authorization: Bearer ...`, which Anthropic answers with HTTP 404, producing a noisy duplicate warning even when the dedicated check passed. Root cause ---------- `hermes_cli/doctor.py:_build_apikey_providers_list` deduplicated profiles against a `_known_canonical` set built from the static list (Z.AI/GLM, Kimi, DeepSeek, …). Providers with their own dedicated check above the generic loop (Anthropic, OpenRouter, Bedrock) were not in that set, so their profiles were appended and ran a second, broken check. Fix --- Add `{"anthropic", "openrouter", "bedrock"}` to the skip set, and also skip profiles whose aliases match any of those names (e.g. `claude`, `claude-oauth` → anthropic). Tests ----- tests/hermes_cli/test_doctor_dedicated_provider_skip.py: - test_build_apikey_providers_list_skips_dedicated_check_providers: asserts the assembled list does not contain anthropic, openrouter, or bedrock entries. - test_build_apikey_providers_list_includes_non_dedicated_providers: sanity guard that legitimate providers (DeepSeek, Z.AI/GLM) survive. Both confirmed via stash-verify (fail pre-fix with anthropic/openrouter leaking, pass post-fix). Fixes #22346
This commit is contained in:
parent
78698381af
commit
1dd0790654
2 changed files with 58 additions and 0 deletions
|
|
@ -245,6 +245,12 @@ def _build_apikey_providers_list() -> list:
|
|||
}
|
||||
for _label, _canonical in _name_to_canonical.items():
|
||||
_known_canonical.add(_canonical)
|
||||
# Providers that already have a dedicated health check above the generic
|
||||
# API-key loop (with custom headers/auth). Skip their pluggable profiles
|
||||
# here so the generic Bearer-auth loop doesn't run a duplicate, broken
|
||||
# check (e.g. Anthropic native API requires x-api-key, not Bearer).
|
||||
_dedicated_canonical = {"anthropic", "openrouter", "bedrock"}
|
||||
_known_canonical.update(_dedicated_canonical)
|
||||
try:
|
||||
from providers import list_providers
|
||||
from providers.base import ProviderProfile as _PP
|
||||
|
|
@ -254,6 +260,8 @@ def _build_apikey_providers_list() -> list:
|
|||
_label = _pp.display_name or _pp.name
|
||||
if _label in _known_names or _pp.name in _known_canonical:
|
||||
continue
|
||||
if any(_alias in _dedicated_canonical for _alias in (_pp.aliases or ())):
|
||||
continue
|
||||
# Separate API-key vars from base-URL override vars — the health-check
|
||||
# loop sends the first found value as Authorization: Bearer, so a URL
|
||||
# string must never be picked.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue