fix(commandcode): degrade to no-op when the deepseek plugin shim is missing

The bundled-plugin loader pops half-registered modules when a plugin
fails to load, so the lazy 'from plugins.model_providers.deepseek import
deepseek' could raise ImportError on every DeepSeek-routed CommandCode
turn — turning the soft 'thinking uncontrollable' bug into a hard
crash. Catch ImportError, log, and return the pre-fix no-op (review
feedback on #95241).
This commit is contained in:
liuhao1024
2026-08-29 00:08:28 +08:00
committed by Teknium
parent 6f88fb030a
commit fbb3a244b7
2 changed files with 30 additions and 2 deletions
@@ -66,8 +66,19 @@ class CommandCodeAnthropicProfile(CommandCodeProfile):
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
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],