The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(models): ProviderProfile.normalize_model_id replaces Copilot id-normalization branches
Teknium96f4499ffdd1
diff --git a/gateway/slash_commands_model.py b/gateway/slash_commands_model.pyindex 8f9479431e3..72cb51dcd64 100644--- a/gateway/slash_commands_model.py+++ b/gateway/slash_commands_model.py@@ -311,7 +311,7 @@ class GatewayModelCommandsMixin:t("gateway.model.switched", model=format_model_for_display(result.new_model)),t("gateway.model.provider_label", provider=result.provider_label or result.target_provider),]- # Provider-aware chain: Codex OAuth, Copilot and Nous caps win over the raw models.dev entry.+ # Provider-aware chain: Codex OAuth, Nous and profile live-catalog caps win over the raw models.dev entry.mi = result.model_infomodel_cfg: dict = {}config_ctx = Nonediff --git a/hermes_cli/cli_model_switch_mixin.py b/hermes_cli/cli_model_switch_mixin.pyindex 91745db9d6c..50cc1132028 100644--- a/hermes_cli/cli_model_switch_mixin.py+++ b/hermes_cli/cli_model_switch_mixin.py@@ -78,7 +78,7 @@ def stored_session_route(session_meta, *, current_model, current_provider):# The endpoint and its wire belong to the provider this chat left; resolve the stored one's own.base_url = api_mode = None# A row's api_mode/base_url were written for whichever model the session last ran. Providers that- # pick the wire per model (OpenCode Zen/Go, Copilot, Nous) re-derive both from the stored model, or a+ # pick the wire per model (OpenCode Zen/Go, Nous, plugin profiles) re-derive both from the stored model, or a# resumed opencode-go session keeps a MiniMax-era anthropic_messages route for a chat_completions# model (#96066) — the CLI/oneshot twin of tui_gateway's _rederive_per_model_route.from hermes_cli.model_switch import model_derived_api_mode@@ -153,7 +153,7 @@ def _print_switch_summary(cli, result, old_model, *, one_turn: bool, strict_cont_acting = f"{agg.get('provider')}:{agg.get('model')}"_cprint(f" {t('cli.model.acting_model', model=_acting)}")- # Provider-aware context chain: Codex OAuth / Copilot / Nous caps win over the raw+ # Provider-aware context chain: Codex OAuth / Nous / profile live-catalog caps win over the raw# models.dev entry (gpt-5.5 is 1.05M on openai but 272K on Codex OAuth).mi = result.model_infoagent = cli.agent@@ -449,12 +449,19 @@ class CLIModelSwitchMixin:except Exception:pass- if resolved_provider == "copilot":- from hermes_cli.models import copilot_model_api_mode, normalize_copilot_model_id+ from providers import get_provider_profile+ profile = get_provider_profile(resolved_provider)+ try:+ native_id = profile.normalize_model_id(current_model, api_key=self.api_key or "") if profile else None+ except Exception: # a plugin hook failing must not block startup: generic repair continues+ logger.debug("normalize_model_id(%s) failed", resolved_provider, exc_info=True)+ native_id = None+ if native_id is not None: # a profile-owned id space also re-derives the wire for the new id+ from hermes_cli.model_switch import model_derived_api_modereturn _adopt_with_mode(- lambda m: normalize_copilot_model_id(m, api_key=self.api_key),- lambda m: copilot_model_api_mode(m, api_key=self.api_key),- lambda new: t("cli.model.normalized_copilot_model", old=current_model, new=new))+ lambda m: native_id,+ lambda m: model_derived_api_mode(resolved_provider, m, self.api_key or "") or self.api_mode,+ lambda new: t("cli.model.normalized_model", old=current_model, new=new, provider=resolved_provider))from hermes_cli.models import opencode_provider_familyif opencode_provider_family(resolved_provider) is not None:diff --git a/hermes_cli/model_normalize.py b/hermes_cli/model_normalize.pyindex 395c536ab56..66dfae00d4d 100644--- a/hermes_cli/model_normalize.py+++ b/hermes_cli/model_normalize.py@@ -2,6 +2,7 @@from __future__ import annotations+import loggingimport refrom typing import Optional@@ -37,7 +38,7 @@ _DOT_TO_HYPHEN_PROVIDERS: frozenset[str] = frozenset({# Providers that want bare names with dots preserved._STRIP_VENDOR_ONLY_PROVIDERS: frozenset[str] = frozenset({- "copilot", "copilot-acp", "openai-codex"})+ "openai-codex"})# Providers whose native naming is authoritative -- pass through unchanged._AUTHORITATIVE_NATIVE_PROVIDERS: frozenset[str] = frozenset({@@ -226,18 +227,18 @@ def normalize_model_for_provider(model_input: str, target_provider: str) -> str:bare = _strip_matching_provider_prefix(name, provider)return bare if "/" in bare else _dots_to_hyphens(bare)- # Copilot's own normalizer knows the alias table (vendor stripping, dash-to-dot repair for Claude)- # and live-catalog lookups; without it dash-notation Claude ids hit HTTP 400 model_not_supported.- # See issue #6879.- if provider in {"copilot", "copilot-acp"}:- try:- from hermes_cli.models import normalize_copilot_model_id-- normalized = normalize_copilot_model_id(name)- if normalized:- return normalized- except Exception:- pass # fall through to the generic strip-vendor behaviour+ # A profile that owns its id space (alias table, dash-to-dot repair) answers first; a wrong+ # notation otherwise hits HTTP 400 model_not_supported. See issue #6879.+ from providers import get_provider_profile++ profile = get_provider_profile(provider)+ try:+ normalized = profile.normalize_model_id(name) if profile is not None else None+ except Exception: # a plugin hook failing must not break normalization: generic rules take over+ logging.getLogger(__name__).debug("normalize_model_id(%s) failed", provider, exc_info=True)+ normalized = None+ if normalized:+ return normalizedif provider in _STRIP_VENDOR_ONLY_PROVIDERS:stripped = _strip_matching_provider_prefix(name, provider)diff --git a/hermes_cli/models_validate.py b/hermes_cli/models_validate.pyindex deefb45603e..e3da968afa6 100644--- a/hermes_cli/models_validate.py+++ b/hermes_cli/models_validate.py@@ -96,7 +96,7 @@ def _match_in_catalog(@dataclassclass _Request:requested: str- lookup: str # id used for catalog membership (copilot-normalized / preset base)+ lookup: str # id used for catalog membership (profile-normalized / preset base)provider: Optional[str] # raw caller value (Ollama checks look at this, not ``normalized``)normalized: strapi_key: Optional[str]@@ -796,9 +796,9 @@ def validate_requested_model(normalized = _m.normalize_provider(provider)if normalized == "openrouter" and base_url and not base_url_host_matches(base_url, "openrouter.ai"):normalized = "custom"- lookup = requested- if normalized == "copilot":- lookup = _m.normalize_copilot_model_id(requested, api_key=api_key) or requested+ from providers import get_provider_profile+ profile = get_provider_profile(normalized) if normalized else None+ lookup = (profile.normalize_model_id(requested, api_key=api_key or "") if profile is not None else None) or requestedif not requested:return _reject("Model name cannot be empty.")diff --git a/locales/af.yaml b/locales/af.yamlindex 4888ed6e1cb..204c396dc6a 100644--- a/locales/af.yaml+++ b/locales/af.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Modelkieser-kasie uitgevee. Verfris..."moa_one_shot_queued: "MoA-eenmalige lopie in tou geplaas met voorafinstelling {preset}; die vorige model word na hierdie beurt herstel."normalized_model: "Model '{old}' genormaliseer na '{new}' vir {provider}."- normalized_copilot_model: "Copilot-model '{old}' genormaliseer na '{new}'."stripped_provider_prefix: "Verskaffervoorvoegsel van '{old}' verwyder; gebruik '{new}' vir {provider}."restored_from_session: "Model vanaf sessie herstel: {model}"could_not_load_config: "❌ kon nie konfigurasie laai nie: {error}"diff --git a/locales/ar.yaml b/locales/ar.yamlindex 6cc7f733567..ef386098e68 100644--- a/locales/ar.yaml+++ b/locales/ar.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "تم مسح ذاكرة التخزين المؤقت لمنتقي النماذج. جارٍ التحديث..."moa_one_shot_queued: "وُضع تشغيل MoA لمرة واحدة في قائمة الانتظار بالإعداد المسبق {preset}؛ سيُستعاد النموذج السابق بعد هذا الدور."normalized_model: "تم تطبيع النموذج '{old}' إلى '{new}' للمزوّد {provider}."- normalized_copilot_model: "تم تطبيع نموذج Copilot '{old}' إلى '{new}'."stripped_provider_prefix: "أُزيلت بادئة المزوّد من '{old}'؛ يُستخدم '{new}' للمزوّد {provider}."restored_from_session: "استُعيد النموذج من الجلسة: {model}"could_not_load_config: "❌ تعذّر تحميل الإعدادات: {error}"diff --git a/locales/de.yaml b/locales/de.yamlindex 380e83bbec2..d42422057a1 100644--- a/locales/de.yaml+++ b/locales/de.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Cache der Modellauswahl gelöscht. Wird aktualisiert..."moa_one_shot_queued: "MoA-Einmaldurchlauf mit Preset {preset} eingereiht; das vorherige Modell wird nach diesem Zug wiederhergestellt."normalized_model: "Modell '{old}' für {provider} zu '{new}' normalisiert."- normalized_copilot_model: "Copilot-Modell '{old}' zu '{new}' normalisiert."stripped_provider_prefix: "Anbieter-Präfix aus '{old}' entfernt; '{new}' wird für {provider} verwendet."restored_from_session: "Modell aus Sitzung wiederhergestellt: {model}"could_not_load_config: "❌ Konfiguration konnte nicht geladen werden: {error}"diff --git a/locales/en.yaml b/locales/en.yamlindex 01e70248657..ecc1d410d34 100644--- a/locales/en.yaml+++ b/locales/en.yaml@@ -2112,7 +2112,6 @@ cli:moa_one_shot_queued: "MoA one-shot queued with preset {preset}; previous model will be restored after this turn."# model-id normalization notices (yellow)normalized_model: "Normalized model '{old}' to '{new}' for {provider}."- normalized_copilot_model: "Normalized Copilot model '{old}' to '{new}'."stripped_provider_prefix: "Stripped provider prefix from '{old}'; using '{new}' for {provider}."restored_from_session: "Model restored from session: {model}"# openai_runtime sub-commanddiff --git a/locales/es.yaml b/locales/es.yamlindex 549254932a3..a07db9c4f88 100644--- a/locales/es.yaml+++ b/locales/es.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Caché del selector de modelos borrada. Actualizando..."moa_one_shot_queued: "MoA de un solo uso en cola con el preajuste {preset}; el modelo anterior se restaurará tras este turno."normalized_model: "Modelo '{old}' normalizado a '{new}' para {provider}."- normalized_copilot_model: "Modelo de Copilot '{old}' normalizado a '{new}'."stripped_provider_prefix: "Se quitó el prefijo de proveedor de '{old}'; se usa '{new}' para {provider}."restored_from_session: "Modelo restaurado desde la sesión: {model}"could_not_load_config: "❌ no se pudo cargar la configuración: {error}"diff --git a/locales/fr.yaml b/locales/fr.yamlindex da45c042079..909dc79ac32 100644--- a/locales/fr.yaml+++ b/locales/fr.yaml@@ -2270,7 +2270,6 @@ cli:cleared_picker_cache: "Cache du sélecteur de modèles vidé. Actualisation..."moa_one_shot_queued: "MoA en une passe mis en file avec le preset {preset} ; le modèle précédent sera rétabli après ce tour."normalized_model: "Modèle '{old}' normalisé en '{new}' pour {provider}."- normalized_copilot_model: "Modèle Copilot '{old}' normalisé en '{new}'."stripped_provider_prefix: "Préfixe de fournisseur retiré de '{old}' ; utilisation de '{new}' pour {provider}."restored_from_session: "Modèle rétabli depuis la session : {model}"could_not_load_config: "❌ impossible de charger la configuration : {error}"diff --git a/locales/ga.yaml b/locales/ga.yamlindex d424d583d91..06e2cb6b1fc 100644--- a/locales/ga.yaml+++ b/locales/ga.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Glanadh taisce roghnóir na samhlacha. Á athnuachan..."moa_one_shot_queued: "Aonurchar MoA curtha i scuaine leis an réamhshocrú {preset}; cuirfear an tsamhail roimhe seo ar ais tar éis an tseala seo."normalized_model: "Normalaíodh an tsamhail '{old}' go '{new}' do {provider}."- normalized_copilot_model: "Normalaíodh samhail Copilot '{old}' go '{new}'."stripped_provider_prefix: "Baineadh réimír an tsoláthraí de '{old}'; ag úsáid '{new}' do {provider}."restored_from_session: "Samhail aischurtha ón seisiún: {model}"could_not_load_config: "❌ níorbh fhéidir an chumraíocht a lódáil: {error}"diff --git a/locales/hu.yaml b/locales/hu.yamlindex 1064ffce16f..ccfab707ddc 100644--- a/locales/hu.yaml+++ b/locales/hu.yaml@@ -2035,7 +2035,6 @@ cli:cleared_picker_cache: "A modellválasztó gyorsítótára törölve. Frissítés..."moa_one_shot_queued: "Egyszeri MoA-futás sorba állítva a {preset} előbeállítással; a kör után az előző modell visszaáll."normalized_model: "A(z) '{old}' modell normalizálva erre: '{new}' ({provider})."- normalized_copilot_model: "A(z) '{old}' Copilot-modell normalizálva erre: '{new}'."stripped_provider_prefix: "A szolgáltató-előtag eltávolítva a(z) '{old}' névről; a(z) '{new}' lesz használva ({provider})."restored_from_session: "Modell visszaállítva a munkamenetből: {model}"could_not_load_config: "❌ nem sikerült betölteni a konfigurációt: {error}"diff --git a/locales/it.yaml b/locales/it.yamlindex a46413bf6db..f6422f808d3 100644--- a/locales/it.yaml+++ b/locales/it.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Cache del selettore di modelli svuotata. Aggiornamento..."moa_one_shot_queued: "MoA one-shot in coda con il preset {preset}; il modello precedente verrà ripristinato dopo questo turno."normalized_model: "Modello '{old}' normalizzato in '{new}' per {provider}."- normalized_copilot_model: "Modello Copilot '{old}' normalizzato in '{new}'."stripped_provider_prefix: "Rimosso il prefisso del provider da '{old}'; uso '{new}' per {provider}."restored_from_session: "Modello ripristinato dalla sessione: {model}"could_not_load_config: "❌ impossibile caricare la configurazione: {error}"diff --git a/locales/ja.yaml b/locales/ja.yamlindex ebc2b1a9842..26245405739 100644--- a/locales/ja.yaml+++ b/locales/ja.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "モデル選択のキャッシュをクリアしました。更新中..."moa_one_shot_queued: "プリセット {preset} で MoA を 1 回だけ実行するようキューに入れました。このターンの後に元のモデルに戻ります。"normalized_model: "{provider} 向けにモデル '{old}' を '{new}' に正規化しました。"- normalized_copilot_model: "Copilot モデル '{old}' を '{new}' に正規化しました。"stripped_provider_prefix: "'{old}' からプロバイダーの接頭辞を取り除き、{provider} では '{new}' を使用します。"restored_from_session: "セッションからモデルを復元しました: {model}"could_not_load_config: "❌ 設定を読み込めませんでした: {error}"diff --git a/locales/ko.yaml b/locales/ko.yamlindex e34a69affda..c68ccf225f4 100644--- a/locales/ko.yaml+++ b/locales/ko.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "모델 선택기 캐시를 지웠어요. 새로 고치는 중..."moa_one_shot_queued: "프리셋 {preset}(으)로 MoA 일회성 실행이 대기열에 추가됐어요. 이 턴이 끝나면 이전 모델로 복원돼요."normalized_model: "{provider}용 모델 '{old}'을(를) '{new}'(으)로 정규화했어요."- normalized_copilot_model: "Copilot 모델 '{old}'을(를) '{new}'(으)로 정규화했어요."stripped_provider_prefix: "'{old}'에서 제공자 접두사를 제거했어요. {provider}에는 '{new}'을(를) 사용해요."restored_from_session: "세션에서 모델 복원됨: {model}"could_not_load_config: "❌ 설정을 불러올 수 없어요: {error}"diff --git a/locales/pt.yaml b/locales/pt.yamlindex ad1b44aff78..96f1b320a54 100644--- a/locales/pt.yaml+++ b/locales/pt.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Cache do seletor de modelos limpo. Atualizando..."moa_one_shot_queued: "MoA de uma vez enfileirado com o preset {preset}; o modelo anterior será restaurado após este turno."normalized_model: "Modelo '{old}' normalizado para '{new}' em {provider}."- normalized_copilot_model: "Modelo Copilot '{old}' normalizado para '{new}'."stripped_provider_prefix: "Prefixo de fornecedor removido de '{old}'; usando '{new}' em {provider}."restored_from_session: "Modelo restaurado da sessão: {model}"could_not_load_config: "❌ não foi possível carregar a configuração: {error}"diff --git a/locales/ru.yaml b/locales/ru.yamlindex c3f1b8de855..506e7c15354 100644--- a/locales/ru.yaml+++ b/locales/ru.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Кэш списка моделей очищен. Обновляю..."moa_one_shot_queued: "Разовый запуск MoA с пресетом {preset} поставлен в очередь; после этого хода вернётся предыдущая модель."normalized_model: "Модель «{old}» нормализована в «{new}» для {provider}."- normalized_copilot_model: "Модель Copilot «{old}» нормализована в «{new}»."stripped_provider_prefix: "Из «{old}» убран префикс провайдера; для {provider} используется «{new}»."restored_from_session: "Модель восстановлена из сеанса: {model}"could_not_load_config: "❌ не удалось загрузить конфигурацию: {error}"diff --git a/locales/tr.yaml b/locales/tr.yamlindex 1d295af27c7..dc0b3ce1b8d 100644--- a/locales/tr.yaml+++ b/locales/tr.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Model seçici önbelleği temizlendi. Yenileniyor..."moa_one_shot_queued: "MoA tek seferlik çalıştırma {preset} ön ayarıyla sıraya alındı; bu turdan sonra önceki model geri yüklenecek."normalized_model: "'{old}' modeli {provider} için '{new}' olarak normalleştirildi."- normalized_copilot_model: "Copilot modeli '{old}', '{new}' olarak normalleştirildi."stripped_provider_prefix: "'{old}' içindeki sağlayıcı öneki kaldırıldı; {provider} için '{new}' kullanılıyor."restored_from_session: "Model oturumdan geri yüklendi: {model}"could_not_load_config: "❌ yapılandırma yüklenemedi: {error}"diff --git a/locales/uk.yaml b/locales/uk.yamlindex 251992da2fd..9384522234c 100644--- a/locales/uk.yaml+++ b/locales/uk.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "Кеш вибору моделей очищено. Оновлення..."moa_one_shot_queued: "Одноразовий запуск MoA поставлено в чергу з пресетом {preset}; попередню модель буде відновлено після цього ходу."normalized_model: "Назву моделі '{old}' нормалізовано до '{new}' для {provider}."- normalized_copilot_model: "Назву моделі Copilot '{old}' нормалізовано до '{new}'."stripped_provider_prefix: "Префікс провайдера прибрано з '{old}'; для {provider} використовується '{new}'."restored_from_session: "Модель відновлено із сеансу: {model}"could_not_load_config: "❌ не вдалося завантажити конфігурацію: {error}"diff --git a/locales/zh-hant.yaml b/locales/zh-hant.yamlindex 293aa5c864b..170907291a8 100644--- a/locales/zh-hant.yaml+++ b/locales/zh-hant.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "已清除模型選擇器快取。正在重新整理..."moa_one_shot_queued: "已排入 MoA 單次執行(預設集 {preset});本輪結束後將還原先前的模型。"normalized_model: "已將 {provider} 的模型 '{old}' 正規化為 '{new}'。"- normalized_copilot_model: "已將 Copilot 模型 '{old}' 正規化為 '{new}'。"stripped_provider_prefix: "已移除 '{old}' 的提供方前綴;{provider} 將使用 '{new}'。"restored_from_session: "已從工作階段還原模型:{model}"could_not_load_config: "❌ 無法載入設定:{error}"diff --git a/locales/zh.yaml b/locales/zh.yamlindex 8f525aedf82..ac3d92c6313 100644--- a/locales/zh.yaml+++ b/locales/zh.yaml@@ -2018,7 +2018,6 @@ cli:cleared_picker_cache: "已清除模型选择器缓存,正在刷新..."moa_one_shot_queued: "已用预设 {preset} 排队一次 MoA 单次运行;本回合结束后将恢复之前的模型。"normalized_model: "已将模型 '{old}' 规范化为 '{new}'(提供方:{provider})。"- normalized_copilot_model: "已将 Copilot 模型 '{old}' 规范化为 '{new}'。"stripped_provider_prefix: "已去掉 '{old}' 中的提供方前缀;将为 {provider} 使用 '{new}'。"restored_from_session: "已从会话恢复模型:{model}"could_not_load_config: "❌ 无法加载配置:{error}"diff --git a/plugins/model-providers/copilot-acp/__init__.py b/plugins/model-providers/copilot-acp/__init__.pyindex 1d52cb3cb5c..f29abac2526 100644--- a/plugins/model-providers/copilot-acp/__init__.py+++ b/plugins/model-providers/copilot-acp/__init__.py@@ -53,6 +53,13 @@ class CopilotACPProfile(ProviderProfile):copilot = get_provider_profile("copilot")return copilot.live_context_length(model, api_key=api_key, base_url=base_url) if copilot else None+ def normalize_model_id(self, model: str, *, api_key: str = "") -> str | None:+ """Copilot id space; the ACP marker key never reaches the HTTP catalog."""+ from providers import get_provider_profile++ copilot = get_provider_profile("copilot")+ return copilot.normalize_model_id(model) if copilot else None+copilot_acp = CopilotACPProfile(name="copilot-acp", aliases=("github-copilot-acp", "copilot-acp-agent"),diff --git a/plugins/model-providers/copilot/catalog.py b/plugins/model-providers/copilot/catalog.pyindex dd07bb82712..538a498f4b7 100644--- a/plugins/model-providers/copilot/catalog.py+++ b/plugins/model-providers/copilot/catalog.py@@ -17,3 +17,8 @@ class CopilotCatalogMixin:from hermes_cli.models import get_copilot_model_contextreturn get_copilot_model_context(model, api_key=api_key)++ def normalize_model_id(self, model: str, *, api_key: str = "") -> str | None:+ from hermes_cli.models import normalize_copilot_model_id++ return normalize_copilot_model_id(model, api_key=api_key or None)diff --git a/providers/base.py b/providers/base.pyindex 04985ea7d19..25bd3c7fbf9 100644--- a/providers/base.py+++ b/providers/base.py@@ -550,3 +550,7 @@ class ProviderProfile:def live_context_length(self, model: str, *, api_key: str = "", base_url: str = "") -> int | None:"""Context window from the provider's live, credentialed catalog; consulted after the persistent cache."""return None++ def normalize_model_id(self, model: str, *, api_key: str = "") -> str | None:+ """Provider-native id for *model* (alias table, catalog repair); None = core's generic normalization."""+ return Nonediff --git a/tests/hermes_cli/test_profile_model_id_seam.py b/tests/hermes_cli/test_profile_model_id_seam.pynew file mode 100644index 00000000000..404e4955f21--- /dev/null+++ b/tests/hermes_cli/test_profile_model_id_seam.py@@ -0,0 +1,41 @@+"""``ProviderProfile.normalize_model_id``: a profile that owns its id space repairs ids before the generic rules."""++from __future__ import annotations++import pytest++import providers+from providers.base import ProviderProfile++NAME = "l4-fake-idspace"+++class _IdSpaceProfile(ProviderProfile):+ def normalize_model_id(self, model, *, api_key=""):+ return {"fancy-4-5": "fancy-4.5"}.get(model.split("/", 1)[-1], model)+++def id_profile(request):+ providers.list_providers()+ providers.register_provider(_IdSpaceProfile(name=NAME, base_url="https://api.idspace.test/v1"))++ def _cleanup():+ providers._REGISTRY.pop(NAME, None)+ providers._PROVIDER_LIST_CACHE = None++ request.addfinalizer(_cleanup)+++def test_profile_normalizer_wins_over_generic_rules(id_profile):+ from hermes_cli.model_normalize import normalize_model_for_provider++ assert normalize_model_for_provider("fancy-4-5", NAME) == "fancy-4.5"+ assert normalize_model_for_provider("vendor/fancy-4-5", NAME) == "fancy-4.5"+++def test_profiles_without_the_hook_keep_generic_normalization():+ from hermes_cli.model_normalize import normalize_model_for_provider++ assert normalize_model_for_provider("openai/gpt-5.4", "openai-codex") == "gpt-5.4"+ assert normalize_model_for_provider("claude-sonnet-4.6", "anthropic") == "claude-sonnet-4-6"