From aff48958d3788a471cc01a0c1db0bedbc9b2febf Mon Sep 17 00:00:00 2001 From: HexLab98 Date: Sat, 25 Jul 2026 12:45:59 +0700 Subject: [PATCH] fix(deepseek): drop retired models from picker and provider defaults Stop offering deepseek-chat/reasoner in the static catalog and point fallback/aux defaults at the permanent v4 IDs. Keep retired aliases in a detection-only map so /model deepseek-chat still resolves to deepseek. --- hermes_cli/models.py | 24 ++++++++++---- plugins/model-providers/deepseek/__init__.py | 32 ++++++++++--------- tests/hermes_cli/test_models.py | 8 ++++- .../model_providers/test_deepseek_profile.py | 32 +++++++++++-------- 4 files changed, 60 insertions(+), 36 deletions(-) diff --git a/hermes_cli/models.py b/hermes_cli/models.py index 3352058a515d..ccf616509487 100644 --- a/hermes_cli/models.py +++ b/hermes_cli/models.py @@ -390,8 +390,6 @@ _PROVIDER_MODELS: dict[str, list[str]] = { "deepseek": [ "deepseek-v4-pro", "deepseek-v4-flash", - "deepseek-chat", - "deepseek-reasoner", ], "xiaomi": [ "mimo-v2.5-pro", @@ -2085,11 +2083,25 @@ def _provider_keys(provider: str) -> set[str]: return {k for k in (key, normalized) if k} +# Retired model IDs kept for /model auto-detect only — not shown in pickers. +# DeepSeek cut these off on 2026-07-24; model_normalize remaps them on the wire. +_PROVIDER_RETIRED_ALIASES: dict[str, tuple[str, ...]] = { + "deepseek": ("deepseek-chat", "deepseek-reasoner"), +} + + +def _provider_catalog_names(provider: str) -> tuple[str, ...]: + """Active picker models plus retired aliases recognized for detection.""" + active = tuple(_PROVIDER_MODELS.get(provider, [])) + retired = _PROVIDER_RETIRED_ALIASES.get(provider, ()) + return active + retired + + def _model_in_provider_catalog(name_lower: str, providers: set[str]) -> bool: return any( name_lower == model.lower() for provider in providers - for model in _PROVIDER_MODELS.get(provider, []) + for model in _provider_catalog_names(provider) ) @@ -2235,7 +2247,7 @@ def detect_static_provider_for_model( current_provider == "custom" or current_provider.startswith("custom:") ) - for pid, models in _PROVIDER_MODELS.items(): + for pid in _PROVIDER_MODELS: if ( pid in current_keys or pid in _AGGREGATOR_PROVIDERS @@ -2244,7 +2256,7 @@ def detect_static_provider_for_model( continue if _is_custom_current: continue - if any(name_lower == m.lower() for m in models): + if any(name_lower == m.lower() for m in _provider_catalog_names(pid)): return (pid, name) # Borrow-list providers (re-expose other vendors' models) only after every @@ -2252,7 +2264,7 @@ def detect_static_provider_for_model( for pid in _BORROWED_MODEL_PROVIDERS: if pid in current_keys: continue - if any(name_lower == m.lower() for m in _PROVIDER_MODELS.get(pid, [])): + if any(name_lower == m.lower() for m in _provider_catalog_names(pid)): return (pid, name) return None diff --git a/plugins/model-providers/deepseek/__init__.py b/plugins/model-providers/deepseek/__init__.py index 8656552e0ddf..cf8c20f2d226 100644 --- a/plugins/model-providers/deepseek/__init__.py +++ b/plugins/model-providers/deepseek/__init__.py @@ -1,11 +1,11 @@ """DeepSeek provider profile. -DeepSeek's V4 family (and the legacy ``deepseek-reasoner``) defaults to -thinking-mode ON when ``extra_body.thinking`` is unset. The API then returns -``reasoning_content`` and starts enforcing the contract that subsequent turns -echo it back; combined with how Hermes replays history this lands on the -notorious HTTP 400 ``reasoning_content must be passed back`` error after the -first tool call (#15700, #17212, #17825). +DeepSeek's V4 family defaults to thinking-mode ON when ``extra_body.thinking`` +is unset. The API then returns ``reasoning_content`` and starts enforcing +the contract that subsequent turns echo it back; combined with how Hermes +replays history this lands on the notorious HTTP 400 +``reasoning_content must be passed back`` error after the first tool call +(#15700, #17212, #17825). This profile overrides :meth:`build_api_kwargs_extras` to mirror the Kimi / Moonshot wire shape that DeepSeek's OpenAI-compat endpoint expects: @@ -13,8 +13,12 @@ Moonshot wire shape that DeepSeek's OpenAI-compat endpoint expects: {"reasoning_effort": "", "extra_body": {"thinking": {"type": "enabled" | "disabled"}}} -Non-thinking models (only ``deepseek-chat`` today, which is V3) are left as -no-ops so we don't perturb the V3 wire format. +Non-thinking models (``deepseek-v3-*`` variants) are left as no-ops so we +don't perturb the V3 wire format. + +The legacy aliases ``deepseek-chat`` / ``deepseek-reasoner`` were retired on +2026-07-24. Use ``deepseek-v4-flash`` or ``deepseek-v4-pro``; Hermes remaps +the retired IDs in ``hermes_cli.model_normalize``. """ from __future__ import annotations @@ -29,8 +33,8 @@ def _model_supports_thinking(model: str | None) -> bool: """DeepSeek thinking-capable model families. Currently covers the V4 family (``deepseek-v4-pro``, ``deepseek-v4-flash``, - and any future ``deepseek-v4-*`` variants) and the legacy - ``deepseek-reasoner`` (R1). ``deepseek-chat`` is V3 with no thinking mode. + and any future ``deepseek-v4-*`` variants). Retired aliases are remapped + before requests leave Hermes, so they are not listed here. """ m = (model or "").strip().lower() if not m: @@ -39,8 +43,6 @@ def _model_supports_thinking(model: str | None) -> bool: # deepseek-v4-*, deepseek-v5-*, etc. — every V4+ generation has # thinking. v3 explicitly excluded. return True - if m == "deepseek-reasoner": - return True return False @@ -90,11 +92,11 @@ deepseek = DeepSeekProfile( description="DeepSeek — native DeepSeek API", signup_url="https://platform.deepseek.com/", fallback_models=( - "deepseek-chat", - "deepseek-reasoner", + "deepseek-v4-pro", + "deepseek-v4-flash", ), base_url="https://api.deepseek.com/v1", - default_aux_model="deepseek-chat", + default_aux_model="deepseek-v4-flash", ) register_provider(deepseek) diff --git a/tests/hermes_cli/test_models.py b/tests/hermes_cli/test_models.py index 89a3d9fed704..0804ee9f5ef1 100644 --- a/tests/hermes_cli/test_models.py +++ b/tests/hermes_cli/test_models.py @@ -252,12 +252,18 @@ class TestDetectProviderForModel: assert result[0] == "anthropic" def test_deepseek_model_detected(self): - """deepseek-chat should resolve to deepseek provider.""" + """Retired deepseek-chat alias still resolves to deepseek for /model.""" result = detect_provider_for_model("deepseek-chat", "openai-codex") assert result is not None # Provider is deepseek (direct) or openrouter (fallback) depending on creds assert result[0] in {"deepseek", "openrouter"} + def test_deepseek_v4_model_detected(self): + """Current DeepSeek V4 IDs resolve to the deepseek provider.""" + result = detect_provider_for_model("deepseek-v4-flash", "openai-codex") + assert result is not None + assert result[0] in {"deepseek", "openrouter"} + def test_current_provider_model_returns_none(self): """Models belonging to the current provider should not trigger a switch.""" assert detect_provider_for_model("gpt-5.3-codex", "openai-codex") is None diff --git a/tests/plugins/model_providers/test_deepseek_profile.py b/tests/plugins/model_providers/test_deepseek_profile.py index 8c316a38086f..d54b291d8d0e 100644 --- a/tests/plugins/model_providers/test_deepseek_profile.py +++ b/tests/plugins/model_providers/test_deepseek_profile.py @@ -1,10 +1,10 @@ """Unit tests for the DeepSeek provider profile's thinking-mode wiring. -DeepSeek V4 (and the legacy ``deepseek-reasoner``) expects every request to -carry an explicit ``extra_body.thinking`` parameter. Omitting it makes the -server default to thinking-mode ON, which then enforces the -``reasoning_content``-must-be-echoed-back contract on subsequent turns and -breaks the conversation with HTTP 400 (#15700, #17212, #17825). +DeepSeek V4 expects every request to carry an explicit ``extra_body.thinking`` +parameter. Omitting it makes the server default to thinking-mode ON, which +then enforces the ``reasoning_content``-must-be-echoed-back contract on +subsequent turns and breaks the conversation with HTTP 400 (#15700, #17212, +#17825). These tests pin the profile's wire-shape contract so DeepSeek requests stay correctly shaped without going live. @@ -106,7 +106,7 @@ class TestDeepSeekThinkingWireShape: class TestDeepSeekModelGating: - """V4 family + ``deepseek-reasoner`` get thinking; V3 stays untouched.""" + """V4 family gets thinking; V3 / unknown stay untouched.""" @pytest.mark.parametrize( "model", @@ -114,7 +114,6 @@ class TestDeepSeekModelGating: "deepseek-v4-pro", "deepseek-v4-flash", "deepseek-v4-future-variant", - "deepseek-reasoner", "DEEPSEEK-V4-PRO", # case-insensitive ], ) @@ -127,7 +126,6 @@ class TestDeepSeekModelGating: @pytest.mark.parametrize( "model", [ - "deepseek-chat", # V3 alias "deepseek-v3-0324", # explicit V3 "deepseek-v3.1", # V3 minor revisions "", # bare/unknown @@ -168,11 +166,11 @@ class TestDeepSeekFullKwargsIntegration: assert kwargs["reasoning_effort"] == "high" assert kwargs["extra_body"] == {"thinking": {"type": "enabled"}} - def test_v3_chat_full_kwargs_omit_thinking(self, deepseek_profile): + def test_v3_full_kwargs_omit_thinking(self, deepseek_profile): from agent.transports.chat_completions import ChatCompletionsTransport kwargs = ChatCompletionsTransport().build_kwargs( - model="deepseek-chat", + model="deepseek-v3-0324", messages=[{"role": "user", "content": "ping"}], tools=None, provider_profile=deepseek_profile, @@ -195,12 +193,18 @@ class TestDeepSeekAuxModel: system. """ - def test_profile_advertises_deepseek_chat(self, deepseek_profile): - assert deepseek_profile.default_aux_model == "deepseek-chat" + def test_profile_advertises_deepseek_v4_flash(self, deepseek_profile): + assert deepseek_profile.default_aux_model == "deepseek-v4-flash" - def test_consumer_api_returns_deepseek_chat(self): + def test_fallback_models_are_v4_only(self, deepseek_profile): + assert deepseek_profile.fallback_models == ( + "deepseek-v4-pro", + "deepseek-v4-flash", + ) + + def test_consumer_api_returns_deepseek_v4_flash(self): from agent.auxiliary_client import _get_aux_model_for_provider - assert _get_aux_model_for_provider("deepseek") == "deepseek-chat" + assert _get_aux_model_for_provider("deepseek") == "deepseek-v4-flash" def test_consumer_api_returns_non_empty(self): from agent.auxiliary_client import _get_aux_model_for_provider