fix(proxy): patch missing reasoning_content in assistant messages for… - #908
Open
mambo-wang wants to merge 4 commits into
Open
Conversation
… DeepSeek thinking mode DeepSeek thinking-mode API rejects message histories where an assistant turn (e.g. a proxy-generated session-init form tool_call) has no reasoning_content, returning HTTP 400. Patch such messages with an empty reasoning_content string before forwarding, which satisfies the API while preserving normal thinking behaviour.
Collaborator
|
感谢提交PR,以下建议麻烦考虑下:
|
- 浠?git 绉婚櫎璇彁浜ょ殑 .codewiki 鍒嗘瀽缂撳瓨锛圫QLite db锛夛紝骞跺湪 .gitignore 涓拷鐣?- CreditPricingEntry 鏂板 requiresReasoningContent 鏍囪锛屼粎瀵规樉寮忔爣璁扮殑 DeepSeek thinking 妯″瀷鍚敤 reasoning_content 琛ヤ竵锛岄伩鍏嶅奖鍝嶉潪 DeepSeek 涓婃父 - 鏇存柊 config.example.yaml 涓?deepseek-v4-pro/flash 娣诲姞鏍囪绀轰緥
Author
|
已修改 |
Collaborator
|
Thank you for your attention and contribution! We will schedule an internal review of this PR, and we will share any feedback right here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… DeepSeek thinking mode
DeepSeek thinking-mode API rejects message histories where an assistant turn (e.g. a proxy-generated session-init form tool_call) has no reasoning_content, returning HTTP 400. Patch such messages with an empty reasoning_content string before forwarding, which satisfies the API while preserving normal thinking behaviour.
Description | 描述
Fix:
MemoryProxy/src/handler.ts—buildUpstreamBody()now callspatchMissingReasoningContent(), which patches assistant messages that lack areasoning_contentfield with an empty string before forwarding.DeepSeek 的 thinking 模式 API 会拒绝消息历史中缺少
reasoning_content的 assistant 消息(例如 proxy 在 session-init 阶段伪造的表单tool_call),返回 HTTP 400:该问题导致任何使用 DeepSeek thinking 模型作为上游的会话初始化流程被阻断:用户走完资产确认表单后,下一个真实请求必然 400,记忆注入也不会生效。
修复已验证(直打 DeepSeek API):补空串 → 200 且保留思考能力;
thinking:{"type":"disabled"}→ 200 但禁用思考。非 assistant 消息及已携带该字段的消息不做处理,对 OpenAI 等其他上游无副作用(body 原样返回)。Related Issue | 关联 Issue
None | 无(部署验证过程中发现的协议兼容性缺陷,无关联 Issue)
Change Type | 修改类型
Self-test Checklist | 自测清单
asset_confirm→ team/agent/task → 注册 → 转发,修复后 200,三条注入 Hook 全部执行,上游reasoning_content可见注入上下文)buildUpstreamBody对无缺失字段的消息返回原 body,非 thinking 上游行为不变)Additional Notes | 其他说明
MemoryProxy/src/handler.ts(+32 行),基于 upstream 最新feat/server_team(fe3230f)创建。thinking:{"type":"disabled"},是为了在满足 API 校验的同时保留模型的正常思考能力。reasoning_content的消息。当前实现作为最小兜底,对任意上游无副作用。