Skip to content

fix: deepseek v4#7823

Merged
Soulter merged 1 commit intomasterfrom
fix/dsv4
Apr 26, 2026
Merged

fix: deepseek v4#7823
Soulter merged 1 commit intomasterfrom
fix/dsv4

Conversation

@Soulter
Copy link
Copy Markdown
Member

@Soulter Soulter commented Apr 26, 2026

fixes: #7782
fixes: #7798

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Handle DeepSeek v4 reasoning models correctly in assistant responses and OpenAI-style payload conversion.

Bug Fixes:

  • Ensure DeepSeek v4 reasoning models always preserve reasoning history parts even when reasoning content is empty.
  • Ensure DeepSeek v4 reasoning models include the reasoning_content field on assistant history messages even when the reasoning text is empty.

@auto-assign auto-assign Bot requested review from Raven95676 and anka-afk April 26, 2026 17:51
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Apr 26, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The DeepSeek reasoning model list ({"deepseek-v4-pro", "deepseek-v4-flash"}) is duplicated across modules; consider centralizing this in a shared constant or helper to avoid divergence when models are added or renamed.
  • In _complete_with_assistant_response, ThinkPart.think is now set to an empty string when there is no reasoning content for DeepSeek models; if downstream consumers distinguish between None and "", it may be safer to preserve the previous semantics or make that behavior explicit.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The DeepSeek reasoning model list (`{"deepseek-v4-pro", "deepseek-v4-flash"}`) is duplicated across modules; consider centralizing this in a shared constant or helper to avoid divergence when models are added or renamed.
- In `_complete_with_assistant_response`, `ThinkPart.think` is now set to an empty string when there is no reasoning content for DeepSeek models; if downstream consumers distinguish between `None` and `""`, it may be safer to preserve the previous semantics or make that behavior explicit.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements special handling for DeepSeek reasoning models to ensure reasoning history is maintained in assistant responses and message payloads, even when the reasoning content is empty. The review feedback highlights an opportunity to centralize the hardcoded list of DeepSeek models to prevent code duplication across multiple files and suggests simplifying the conditional logic used to assign reasoning content in the OpenAI source provider.

Comment thread astrbot/core/provider/sources/openai_source.py Outdated
Comment thread astrbot/core/provider/sources/openai_source.py Outdated
Co-authored-by: Copilot <copilot@github.com>
@Soulter Soulter merged commit 07b37b9 into master Apr 26, 2026
20 checks passed
if reasoning_content:
if is_deepseek_v4_reasoning and not reasoning_content:
logger.info(
"Deepseek v4 model requires non-empty reasoning content, but got empty. Setting to 'none' to satisfy the requirement."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

2 participants