Skip to content

The agent that grows with you

fix(providers): give alibaba-coding-plan-cn its own API key env var

Edizzier805498e6dfed
diff --git a/plugins/model-providers/alibaba-coding-plan/__init__.py b/plugins/model-providers/alibaba-coding-plan/__init__.py
index b420fbbbd99..4723606d0e2 100644
--- a/plugins/model-providers/alibaba-coding-plan/__init__.py
+++ b/plugins/model-providers/alibaba-coding-plan/__init__.py
@@ -9,6 +9,10 @@ Region split, mirroring the base DashScope pair (#73265):
Profile names match the models.dev catalog keys exactly so model metadata
lines up and ``model.provider: alibaba-coding-plan-cn`` resolves at runtime.
+
+The CN profile checks its own ``ALIBABA_CODING_PLAN_CN_API_KEY`` first (#101122,
+mirroring kimi-coding-cn) and keeps the shared vars as ordered fallbacks so
+existing CN users configured with the shared key keep working.
"""
from providers import register_provider
@@ -31,7 +35,7 @@ alibaba_coding_plan_cn = ProviderProfile(
display_name="Alibaba Cloud (Coding Plan, China)",
description="Alibaba Cloud Coding Plan, mainland-China endpoint",
signup_url="https://help.aliyun.com/zh/model-studio/",
- env_vars=("ALIBABA_CODING_PLAN_API_KEY", "DASHSCOPE_API_KEY", "ALIBABA_CODING_PLAN_CN_BASE_URL"),
+ env_vars=("ALIBABA_CODING_PLAN_CN_API_KEY", "ALIBABA_CODING_PLAN_API_KEY", "DASHSCOPE_API_KEY", "ALIBABA_CODING_PLAN_CN_BASE_URL"),
base_url="https://coding.dashscope.aliyuncs.com/v1",
auth_type="api_key",
)
diff --git a/tests/hermes_cli/test_alibaba_coding_plan_cn_provider_listing.py b/tests/hermes_cli/test_alibaba_coding_plan_cn_provider_listing.py
new file mode 100644
index 00000000000..6dc59e3338f
--- /dev/null
+++ b/tests/hermes_cli/test_alibaba_coding_plan_cn_provider_listing.py
@@ -0,0 +1,30 @@
+"""alibaba-coding-plan and alibaba-coding-plan-cn must not both appear in the
+/model picker off a single shared key (#101122).
+
+The CN profile now has its own ALIBABA_CODING_PLAN_CN_API_KEY (checked first),
+keeping the shared ALIBABA_CODING_PLAN_API_KEY / DASHSCOPE_API_KEY as ordered
+fallbacks so existing CN users are not broken. The picker hides a ``-cn`` row
+whose only lit vars are shared with a lit non-CN sibling row.
+"""
+
+import os
+from unittest.mock import patch
+
+from hermes_cli.model_switch import list_authenticated_providers
+
+_CLEAR = {k: "" for k in ("ALIBABA_CODING_PLAN_API_KEY", "ALIBABA_CODING_PLAN_CN_API_KEY", "DASHSCOPE_API_KEY")}
+
+
+def _alibaba_slugs(current_provider=""):
+ return [p["slug"] for p in list_authenticated_providers(current_provider=current_provider) if "coding-plan" in p["slug"]]
+
+
[email protected](os.environ, {**_CLEAR, "ALIBABA_CODING_PLAN_CN_API_KEY": "sk-cn-fake"}, clear=False)
+def test_alibaba_cn_appears_when_only_cn_key_set():
+ assert _alibaba_slugs() == ["alibaba-coding-plan-cn"]
+
+
[email protected](os.environ, {**_CLEAR, "ALIBABA_CODING_PLAN_API_KEY": "sk-intl-fake"}, clear=False)
+def test_alibaba_cn_does_not_appear_when_only_intl_key_set():
+ """#101122: the shared intl key alone must light only the intl row."""
+ assert _alibaba_slugs() == ["alibaba-coding-plan"]