refactor(commandcode): drop the deepseek ImportError guard, trim tests to two invariants

The deepseek plugin is bundled and always loads, so the try/except around
the delegation import was defense-in-depth for a path that cannot fail.
Tests reduced to the two contracts that matter: /reasoning none reaches
the wire as thinking.disabled, and DeepSeek ids produce exactly the native
DeepSeek profile's output while non-DeepSeek families stay a no-op.
This commit is contained in:
teknium1
2026-09-12 19:16:22 -07:00
committed by Teknium
parent fbb3a244b7
commit baf1200e0a
2 changed files with 31 additions and 108 deletions
+17 -37
View File
@@ -38,6 +38,23 @@ class CommandCodeProfile(ProviderProfile):
return None
def build_api_kwargs_extras(
self, *, reasoning_config: dict | None = None, model: str | None = None, **context
) -> tuple[dict, dict]:
"""DeepSeek ids (``deepseek/deepseek-v4-flash``) get the native DeepSeek wire
controls: DeepSeek V4+ defaults to thinking when ``thinking`` is omitted, so
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/"):
return {}, {}
from plugins.model_providers.deepseek import deepseek as _deepseek_profile
return _deepseek_profile.build_api_kwargs_extras(
reasoning_config=reasoning_config, model=m.split("/", 1)[1], **context,
)
class CommandCodeAnthropicProfile(CommandCodeProfile):
"""CommandCode — Anthropic Messages API-compatible endpoint."""
@@ -48,43 +65,6 @@ class CommandCodeAnthropicProfile(CommandCodeProfile):
all_models = super().fetch_models(api_key=api_key, base_url=base_url, timeout=timeout)
return None if all_models is None else [m for m in all_models if m.startswith("claude-")]
def build_api_kwargs_extras(
self, *, reasoning_config: dict | None = None, model: str | None = None, **context
) -> tuple[dict, dict]:
"""Apply the native DeepSeek reasoning controls for DeepSeek-family ids.
CommandCode fronts DeepSeek with vendor-prefixed ids
(``deepseek/deepseek-v4-flash``). DeepSeek V4+ defaults to thinking
mode when the ``thinking`` field is omitted, so without an explicit
wire control a Hermes ``/reasoning none`` changes the session state
but not the actual request — the turn sits in
``reflecting.../brainstorming...`` for minutes (#95232). Strip the
vendor prefix and delegate to the native DeepSeek profile's logic
(extra_body.thinking + reasoning_effort mapping); other CommandCode
model families keep the base no-op behavior.
"""
m = (model or "").strip()
if not m.lower().startswith("deepseek/") or len(m) <= len("deepseek/"):
return {}, {}
try:
from plugins.model_providers.deepseek import deepseek as _deepseek_profile
except ImportError:
# The bundled-plugin loader tolerates a plugin failing to load
# (it pops the half-registered module and continues), so the
# shim may be absent. Degrade to the pre-fix no-op instead of
# crashing every DeepSeek-routed CommandCode turn.
logger.warning(
"DeepSeek provider plugin unavailable; CommandCode cannot "
"forward reasoning controls (#95232)",
exc_info=True,
)
return {}, {}
return _deepseek_profile.build_api_kwargs_extras(
reasoning_config=reasoning_config,
model=m.split("/", 1)[1],
**context,
)
commandcode = CommandCodeProfile(
name="commandcode", aliases=("commandcode-chat",), api_mode="chat_completions",