Skip to content

The agent that grows with you

fix(agent): normalize custom provider route identity

Blood Shot0204e4898e4a
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.py
index 861c4d23252..336cd6174ae 100644
--- a/agent/agent_runtime_helpers.py
+++ b/agent/agent_runtime_helpers.py
@@ -2330,6 +2330,9 @@ def anthropic_prompt_cache_policy(
_provider_ids = {provider_lower}
if provider_lower.startswith("custom:"):
_provider_ids.add(provider_lower.removeprefix("custom:"))
+ from hermes_cli.route_identity import normalize_route_base_url
+
+ _runtime_route_url = normalize_route_base_url(eff_base_url)
for _entry in _custom_providers:
if not isinstance(_entry, dict):
continue
@@ -2338,8 +2341,9 @@ def anthropic_prompt_cache_policy(
str(_entry.get("provider_key") or "").strip().lower(),
}
if _provider_ids & (_entry_ids - {""}) or (
- eff_base_url
- and str(_entry.get("base_url") or "") == eff_base_url
+ _runtime_route_url
+ and normalize_route_base_url(_entry.get("base_url"))
+ == _runtime_route_url
):
_route_may_be_custom = True
break
diff --git a/tests/run_agent/test_anthropic_prompt_cache_policy.py b/tests/run_agent/test_anthropic_prompt_cache_policy.py
index 0e4e1668a4f..a4d8a2d35db 100644
--- a/tests/run_agent/test_anthropic_prompt_cache_policy.py
+++ b/tests/run_agent/test_anthropic_prompt_cache_policy.py
@@ -326,6 +326,13 @@ class TestCustomProviderOpenAIWireCapability:
assert agent._anthropic_prompt_cache_policy() == (False, False)
+ def test_equivalent_base_url_spelling_reaches_capability_lookup(self):
+ agent = self._configured_agent(enabled=True)
+ agent.provider = "unrelated-runtime-alias"
+ agent._custom_providers[0]["base_url"] = "HTTPS://models.example.net/v1/"
+
+ assert agent._anthropic_prompt_cache_policy() == (True, False)
+
def test_undeclared_chat_completions_route_stays_conservative(self):
agent = self._configured_agent(enabled=True)
agent._custom_providers[0]["models"]["vendor-agnostic-model"] = {