fix: avoid custom provider shadowing built-in providers

Follow up on salvaged PR #1012.
Prevents raw custom-provider names from intercepting built-in provider ids,
and keeps the regression coverage focused on current-main behavior.
This commit is contained in:
teknium1 2026-03-14 11:24:29 -07:00
parent 4422637e7a
commit 88951215d3
2 changed files with 37 additions and 13 deletions

View file

@ -5,6 +5,7 @@ from __future__ import annotations
import os
from typing import Any, Dict, Optional
from hermes_cli import auth as auth_mod
from hermes_cli.auth import (
AuthError,
PROVIDER_REGISTRY,
@ -56,6 +57,19 @@ def _get_named_custom_provider(requested_provider: str) -> Optional[Dict[str, An
if not requested_norm or requested_norm == "custom":
return None
# Raw names should only map to custom providers when they are not already
# valid built-in providers or aliases. Explicit menu keys like
# ``custom:local`` always target the saved custom provider.
if requested_norm == "auto":
return None
if not requested_norm.startswith("custom:"):
try:
auth_mod.resolve_provider(requested_norm)
except AuthError:
pass
else:
return None
config = load_config()
custom_providers = config.get("custom_providers")
if not isinstance(custom_providers, list):