From ef754d75bac2be3a26e25ee711c904dfaa5983f1 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:27:28 +0530 Subject: [PATCH] refactor(commandcode): resolve the native DeepSeek profile through the registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The delegation imported ``plugins.model_providers.deepseek`` — the only cross-plugin module import in the tree, and one that resolves solely through the loader's sys.modules shim (popped again if the deepseek plugin fails to load). Look the profile up with get_provider_profile("deepseek") instead: already imported from ``providers``, honours a user override of the profile, degrades to the base no-op without a try/except. Drop the ``len(m) <= len("deepseek/")`` guard — the native profile returns ({}, {}) for an empty id anyway. Bind the expected value in the parity test and assert it is non-empty so the equality cannot pass as ({}, {}) == ({}, {}). --- plugins/model-providers/commandcode/__init__.py | 13 ++++++++----- .../model_providers/test_commandcode_profile.py | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/model-providers/commandcode/__init__.py b/plugins/model-providers/commandcode/__init__.py index 0f57962c25..bd2aebbe05 100644 --- a/plugins/model-providers/commandcode/__init__.py +++ b/plugins/model-providers/commandcode/__init__.py @@ -7,7 +7,7 @@ import logging import urllib.request from hermes_cli.urllib_security import open_credentialed_url -from providers import register_provider +from providers import get_provider_profile, register_provider from providers.base import ProviderProfile, _profile_user_agent logger = logging.getLogger(__name__) @@ -47,11 +47,14 @@ class CommandCodeProfile(ProviderProfile): without them ``/reasoning`` never reaches the request (#95232). Other model families stay a no-op — CommandCode declares no reasoning vocabulary for them.""" m = (model or "").strip() - if not m.lower().startswith("deepseek/") or len(m) <= len("deepseek/"): + if not m.lower().startswith("deepseek/"): return {}, {} - from plugins.model_providers.deepseek import deepseek as _deepseek_profile - - return _deepseek_profile.build_api_kwargs_extras( + # Registry lookup, not a module import: the deepseek shim is only a loader-injected + # sys.modules entry, and the registry honours a user override of the profile. + native = get_provider_profile("deepseek") + if native is None: + return {}, {} + return native.build_api_kwargs_extras( reasoning_config=reasoning_config, model=m.split("/", 1)[1], **context, ) diff --git a/tests/plugins/model_providers/test_commandcode_profile.py b/tests/plugins/model_providers/test_commandcode_profile.py index dd7537e19f..f33e58fd16 100644 --- a/tests/plugins/model_providers/test_commandcode_profile.py +++ b/tests/plugins/model_providers/test_commandcode_profile.py @@ -100,9 +100,11 @@ class TestCommandCodeReasoningWireControls: from plugins.model_providers.deepseek import deepseek rc = {"enabled": True, "effort": "low"} + expected = deepseek.build_api_kwargs_extras(reasoning_config=rc, model="deepseek-v4.1-flash") + assert expected[1].get("reasoning_effort") == "low" # equality below must not be ({}, {}) == ({}, {}) assert commandcode_profile.build_api_kwargs_extras( reasoning_config=rc, model="deepseek/deepseek-v4.1-flash" - ) == deepseek.build_api_kwargs_extras(reasoning_config=rc, model="deepseek-v4.1-flash") + ) == expected assert commandcode_profile.build_api_kwargs_extras( reasoning_config=rc, model="Qwen/Qwen3.7-Max" ) == ({}, {})