The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(config): expose a custom route's canonical api_mode for metadata lookups
JoaoMarcos44193e5684946f
diff --git a/hermes_cli/config.py b/hermes_cli/config.pyindex efbb46a296a..9dc6783cf2e 100644--- a/hermes_cli/config.py+++ b/hermes_cli/config.py@@ -708,7 +708,7 @@ from hermes_cli.config_providers import ( # noqa: E402,F401 (re-exported; call_pick_provider_base_url, _route_model_cfg, _warn_once_per_provider,apply_custom_provider_extra_headers_to_client_kwargs,apply_custom_provider_tls_to_client_kwargs, coerce_provider_id, find_provider_entry,- get_compatible_custom_providers, get_custom_provider_context_length,+ get_compatible_custom_providers, get_custom_provider_api_mode, get_custom_provider_context_length,get_custom_provider_extra_headers, get_custom_provider_model_capability,get_custom_provider_session_affinity_header,get_custom_provider_tls_settings, is_provider_enabled, normalize_extra_headers,diff --git a/hermes_cli/config_providers.py b/hermes_cli/config_providers.pyindex 19eeab13a0b..10401602642 100644--- a/hermes_cli/config_providers.py+++ b/hermes_cli/config_providers.py@@ -389,6 +389,25 @@ def _entries_for_route(yield entry+def get_custom_provider_api_mode(+ base_url: str,+ custom_providers: Optional[List[Dict[str, Any]]] = None,+ config: Optional[Dict[str, Any]] = None,+) -> str:+ """Canonical ``api_mode`` of the first custom entry serving *base_url*, or ``""``.++ Route identity is the URL, not the host: a Codex proxy on ``127.0.0.1`` declares its wire+ protocol here and nowhere else, so metadata lookups keyed on the transport read it from the+ entry instead of guessing from the hostname (#116191).+ """+ for entry in _entries_for_route(base_url, custom_providers, config):+ for field in ("api_mode", "transport"):+ value = entry.get(field)+ if isinstance(value, str) and value.strip():+ return _canonical_api_mode(value)+ return ""++def _route_model_cfg(entry: Dict[str, Any], model: str) -> Optional[Dict[str, Any]]:"""Return ``entry.models[model]`` when both are mappings, else None."""models = entry.get("models")