refactor(commandcode): resolve the native DeepSeek profile through the registry
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 ({}, {}) == ({}, {}).
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
@@ -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"
|
||||
) == ({}, {})
|
||||
|
||||
Reference in New Issue
Block a user