Skip to content

fix(deepseek): 补齐原生协议字段兼容 - #638

Merged
tbphp merged 3 commits into
mainfrom
tbphp/deepseek-native-compat
Sep 13, 2026
Merged

fix(deepseek): 补齐原生协议字段兼容#638
tbphp merged 3 commits into
mainfrom
tbphp/deepseek-native-compat

Conversation

@tbphp

@tbphp tbphp commented Sep 13, 2026

Copy link
Copy Markdown
Owner

关联 Issue / Related Issue

无。

变更内容 / Change Content

  • Bug 修复 / Bug fix

DeepSeek 原生接口存在角色、思考字段及默认思考与强制工具调用的兼容差异。本次在 DeepSeek 原生请求发送前做最小字段适配:

  • Completions 不接受 developer,Responses 将其当作普通用户消息:纯文本 developer 原位映射为 system,保留指令内容及位置。
  • Completions 的 assistant 消息已有文本 reasoning 且缺少 reasoning_content 时,补充后者,保留原字段及已有标准字段值。
  • 强制工具调用且未配置思考时,关闭 DeepSeek 默认思考:Completions/Anthropic 设置 thinking.type=disabled,Responses 设置 reasoning.effort=none。已指定思考开关或强度时保留原值,显式冲突仍由上游返回错误。自动工具选择保持原样。

不增删、合并或重排消息,不修改亲和、路由、调度和其他渠道;保留此前 Codex/Grok 中途系统指令修复。Responses 与 Anthropic 继续原生转发思考内容,不补造缺失的思考原文。无数据迁移。

验证:

  • make check、Bifrost 全包测试及 git --no-pager diff --check 通过。
  • 回归覆盖三种协议普通/流式请求、强制与指定工具、显式思考配置保留、多轮历史前缀与工具顺序、原始请求和亲和字段保留、其他渠道不受影响。
  • 尚未使用真实 DeepSeek 上游验收。

自查清单 / Checklist

  • 已运行 make check,验证范围见上。
  • 本 PR 范围聚焦,未包含无关改动。
  • 已评估公开文档与发布说明,本次无需更新。
  • 提交、日志和测试数据不包含敏感信息。
  • 已说明兼容性及数据迁移影响。

Copilot AI lite review requested due to automatic review settings September 13, 2026 02:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-13T03:08:21.970089Z 9c35775 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Advanced

Run ID: 80096514-7ed2-4e8c-b023-12f673d0b6a8

📥 Commits

Reviewing files that changed from the base of the PR and between cc24f6b and 9c35775.

📒 Files selected for processing (2)
  • internal/execution/bifrost/deepseek_native.go
  • internal/execution/bifrost/deepseek_native_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

新增 DeepSeek 原生请求规范化逻辑。Completions 使用 messages,Responses 使用 input。纯文本 developer 消息转换为 system。Completions 中的字符串 reasoning 可复制为 reasoning_content。强制工具调用且未配置思考模式时,按协议写入默认禁用思考配置。执行器仅在 DeepSeek 原生透传路径调用该逻辑。新增测试覆盖多协议、流式请求、非流式请求及不支持内容。

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 9c357

强制 Web Search 请求可能因默认思考模式被 DeepSeek 拒绝。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次 PR 的主要变更,即修复 DeepSeek 原生协议字段兼容问题。标题简洁且与变更内容一致。
Description check ✅ Passed PR 描述完整说明了变更内容、兼容规则、测试范围、未验证范围及自查结果。关联 Issue 填写为“无”,未提供 Issue 编号,但不影响对本次变更的理解。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5810c660c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/execution/bifrost/deepseek_native.go Outdated
@tbphp tbphp self-assigned this Sep 13, 2026
@tbphp tbphp added the bug Something isn't working label Sep 13, 2026
@tbphp tbphp added this to the v2.0.0 milestone Sep 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Advanced

Run ID: 10b105f7-c3f1-4fb3-9403-2b05a3d15f66

📥 Commits

Reviewing files that changed from the base of the PR and between c5810c6 and cc24f6b.

📒 Files selected for processing (3)
  • internal/execution/bifrost/deepseek_native.go
  • internal/execution/bifrost/deepseek_native_test.go
  • internal/execution/bifrost/native_fidelity_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment thread internal/execution/bifrost/deepseek_native.go
@tbphp

tbphp commented Sep 13, 2026

Copy link
Copy Markdown
Owner Author

关于汇总评论中的 Docstring Coverage:不采纳为达到 80% 而补充注释的建议。仓库未设置此门禁,关键兼容行为已有注释,保留当前最小改动;Web 搜索意见已在对应行内线程说明。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c35775fa3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +72 to +74
case protocol.OpenAIResponses:
forced = choice.String() == "required" ||
(choice.Get("type").String() == "function" && choice.Get("name").String() != "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable thinking for required allowed-tool choices

For a DeepSeek native Responses request with tool_choice: {"type":"allowed_tools","mode":"required",...}, this condition leaves forced false, so the request is sent without reasoning.effort="none" and DeepSeek's default thinking can conflict with the required tool call. The converted-path guard in deepSeekConversionDisablesThinking already classifies ChatToolChoiceTypeAllowedTools as a forced selection; inspect the nested mode here as well so native Responses requests receive the same compatibility handling.

Useful? React with 👍 / 👎.

@tbphp
tbphp merged commit f8a04df into main Sep 13, 2026
11 checks passed
@tbphp
tbphp deleted the tbphp/deepseek-native-compat branch September 13, 2026 03:42
DabengBa pushed a commit to DabengBa/gpt-load that referenced this pull request Sep 13, 2026
* fix(deepseek): 补齐原生协议字段兼容

* fix(deepseek): 兼容强制工具调用与默认思考

* fix(deepseek): 跳过空思考字段别名

(cherry picked from commit f8a04df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants