The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(provider): honor explicit local provider names
fangliquan8658d15957d9
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex c86c5717aa4..505f822cf9b 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -5374,10 +5374,11 @@ def resolve_provider_client(explicit_base_url, explicit_api_key, api_mode, main_runtime, is_vision, task,)branch = _EXPLICIT_PROVIDER_BRANCHES.get(provider)+ alias_identity = original_provider.removeprefix("custom:")# A configured provider whose name collides with a local-server alias is still a named# provider. Resolve it before the alias's generic ``custom`` branch, which otherwise loses# the configured base_url and can fall through to an unrelated credentialed provider.- if branch is None or original_provider in _LOCAL_SERVER_ALIASES:+ if branch is None or alias_identity in _LOCAL_SERVER_ALIASES:try:result = _resolve_named_custom_branch(req)except ImportError:diff --git a/tests/agent/test_auxiliary_named_custom_providers.py b/tests/agent/test_auxiliary_named_custom_providers.pyindex 5f1098398dd..dbff6b08266 100644--- a/tests/agent/test_auxiliary_named_custom_providers.py+++ b/tests/agent/test_auxiliary_named_custom_providers.py@@ -394,7 +394,8 @@ class TestCustomProviderAliasCollision:# Built-in kimi-coding points at api.moonshot.aiassert "moonshot" in base_url or "kimi" in base_url, f"unexpected base_url {base_url!r}"- def test_named_llamacpp_wins_over_local_server_alias(self, tmp_path):+ @pytest.mark.parametrize("provider", ["llamacpp", "custom:llamacpp"])+ def test_named_llamacpp_wins_over_local_server_alias(self, tmp_path, provider):_write_config(tmp_path, {"model": {"provider": "openrouter", "default": "anthropic/claude-sonnet-4.6"},"providers": {@@ -407,7 +408,7 @@ class TestCustomProviderAliasCollision:from agent.auxiliary_client import resolve_provider_clientfrom openai import OpenAI- client, model = resolve_provider_client("llamacpp", model="local-model", raw_codex=True)+ client, model = resolve_provider_client(provider, model="local-model", raw_codex=True)assert isinstance(client, OpenAI)assert str(client.base_url).rstrip("/") == "http://127.0.0.1:8081/v1"