The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: explicit launch key wins over the bare-custom pool too
Tekniumca2c115d1935
diff --git a/hermes_cli/runtime_provider_backends.py b/hermes_cli/runtime_provider_backends.pyindex f257277bcf4..b6f0a5f8547 100644--- a/hermes_cli/runtime_provider_backends.py+++ b/hermes_cli/runtime_provider_backends.py@@ -189,7 +189,8 @@ def _resolve_openrouter_runtime(if requested_norm != "custom":return rp._runtime("openrouter", cfg_api_mode or rp._detect_api_mode_for_url(base_url) or "chat_completions", base_url,api_key, source=source)- if base_url:+ # An explicit launch key is the operator's credential for this route and wins over the pool (R2-M1).+ if base_url and not rp.has_usable_secret(explicit_api_key):pool_result = rp._try_resolve_from_custom_pool(base_url, "custom", cfg_api_mode, provider_name=None)if pool_result:return pool_resultdiff --git a/tests/hermes_cli/test_runtime_provider_resolution.py b/tests/hermes_cli/test_runtime_provider_resolution.pyindex 04c24f5537c..fe954e144f9 100644--- a/tests/hermes_cli/test_runtime_provider_resolution.py+++ b/tests/hermes_cli/test_runtime_provider_resolution.py@@ -2367,3 +2367,16 @@ def test_openai_alias_without_base_url_pairs_openai_key_with_openai_base_url(monruntime = rp.resolve_runtime_provider(requested="openai", target_model="gpt-x")assert (runtime["provider"], runtime["base_url"], runtime["api_key"]) == ("custom", "https://llm-proxy.corp.example/v1", "sk-proxy-issued")+++def test_bare_custom_explicit_launch_key_wins_over_custom_pool(monkeypatch):+ """R2-M1: on the bare-custom terminal rung a launch ``--api-key`` must not be replaced by a+ pooled credential for the same URL (named-custom and direct-alias already honour it)."""+ from hermes_cli.runtime_provider_backends import _resolve_openrouter_runtime++ monkeypatch.setattr(rp, "_get_model_config", lambda: {"provider": "custom"})+ monkeypatch.setattr(rp, "_try_resolve_from_custom_pool", lambda *a, **k: {+ "provider": "custom", "base_url": "http://127.0.0.1:9/v1", "api_key": "sk-pooled", "source": "pool"})+ resolved = _resolve_openrouter_runtime(requested_provider="custom", explicit_api_key="sk-launch-explicit",+ explicit_base_url="http://127.0.0.1:9/v1")+ assert resolved["api_key"] == "sk-launch-explicit"