From 8ca575bdeb4d9d4c81e8ecd22b5ada7e17362cdc Mon Sep 17 00:00:00 2001 From: Jiajun Xie Date: Thu, 30 Apr 2026 12:52:45 +0000 Subject: [PATCH] fix: adjust DeepSeek reasoning mode check condition - Modified _drop_deepseek_incomplete_reasoning_history to properly handle reasoning mode detection - Fixes issue #3554 --- nanobot/providers/openai_compat_provider.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nanobot/providers/openai_compat_provider.py b/nanobot/providers/openai_compat_provider.py index 6712b68bc..251568afc 100644 --- a/nanobot/providers/openai_compat_provider.py +++ b/nanobot/providers/openai_compat_provider.py @@ -457,11 +457,16 @@ class OpenAICompatProvider(LLMProvider): if ( not self._spec or self._spec.name != "deepseek" - or not reasoning_effort - or reasoning_effort.lower() == "none" ): return messages + # For DeepSeek models, always check for incomplete reasoning history + # when thinking mode might be active. reasoning_effort may not be set + # explicitly but the model could still be using thinking mode by default. + # Only skip this check when reasoning_effort is explicitly set to "none". + if reasoning_effort is not None and reasoning_effort.lower() == "none": + return messages + bad_idx = None for idx, msg in enumerate(messages): if (