The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(runtime): drop the dead urlparse import; pin the bare-host-default fail-open
kshitijk4poor07fccd3114f3
diff --git a/hermes_cli/runtime_provider.py b/hermes_cli/runtime_provider.pyindex 2d67899281b..68da8dec168 100644--- a/hermes_cli/runtime_provider.py+++ b/hermes_cli/runtime_provider.py@@ -11,7 +11,6 @@ import loggingimport refrom dataclasses import dataclassfrom typing import Any, Callable, Dict, Optional-from urllib.parse import urlparselogger = logging.getLogger(__name__)@@ -162,9 +161,10 @@ def _on_declared_anthropic_endpoint(provider: str, base_url: str) -> bool:default's host (or a subdomain of it) and either the bare host — the provider's own hostwith no path still means the native endpoint (#53054) — or the default's path(``/anthropic`` for MiniMax, ``/plan/anthropic`` for Tencent) with or without a ``/v1``- tail. With nothing to compare — no URL, no path on the default, or an overlay-only- provider whose models.dev default is not cached (offline) — keep the declared transport:- demoting the provider's own default endpoint would be the worse failure."""+ tail. With nothing to compare — no URL, an overlay-only provider whose models.dev default+ is not cached (offline), or a default with no path at all (``api.anthropic.com``: no sibling+ OpenAI-compatible path exists to tell an override's protocol from) — keep the declared+ transport: demoting the provider's own endpoint would be the worse failure."""pdef = get_provider(provider, allow_network=False)default = (pdef.base_url if pdef else "").strip()default_path = base_url_path(default).removesuffix("/v1")diff --git a/tests/hermes_cli/test_runtime_transport_precedence.py b/tests/hermes_cli/test_runtime_transport_precedence.pyindex 667d868947c..2b8855d0531 100644--- a/tests/hermes_cli/test_runtime_transport_precedence.py+++ b/tests/hermes_cli/test_runtime_transport_precedence.py@@ -54,12 +54,13 @@ class TestFallbackApiMode:"minimax": "https://api.minimax.io/anthropic/v1","minimax-cn": "https://api.minimaxi.com/anthropic/v1","tencent-tokenplan": "https://api.lkeap.cloud.tencent.com/plan/anthropic",+ "anthropic": "https://api.anthropic.com",}real = runtime_provider.get_providerdef seeded(name, *, allow_network=True):- # allow_network is dropped so the fixture can never reach models.dev; replace, not- # assign, because get_provider hands back the cached ProviderDef other tests share.+ # allow_network is dropped so the fixture can never reach models.dev; replace()+ # rather than mutate so the fixture never depends on get_provider's object identity.# Seed unconditionally: a warm disk cache must not swap in whatever models.dev# publishes today.pdef = real(name, allow_network=False)@@ -90,6 +91,7 @@ class TestFallbackApiMode:("minimax", "https://api.minimax.io/anthropic/v1/messages"), # under the default path("tencent-tokenplan", "https://api.lkeap.cloud.tencent.com/plan/anthropic/v2"), # non-/anthropic default("minimax", ""), # nothing to compare: keep the declared transport+ ("anthropic", "http://127.0.0.1:4000/v1"), # bare-host default: relays serve /v1/messages])def test_anthropic_transport_holds_on_the_provider_endpoint(self, provider, base_url):assert _fallback_api_mode(provider, base_url, "MiniMax-M3") == "anthropic_messages"