-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(deepseek): support native tool calling for deepseek-reasoner V3.2 #9746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(deepseek): support native tool calling for deepseek-reasoner V3.2 #9746
Conversation
- Add custom createMessage override for DeepSeekHandler - Use convertToOpenAiMessages for native tool protocol to properly handle tool_calls in assistant messages and tool role messages for results - Create dedicated OpenAI client for native tool calling support - Delegate to parent implementation for XML protocol or deepseek-chat model Reference: https://api-docs.deepseek.com/zh-cn/guides/thinking_mode#工具调用
Review complete. The change adds Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Added defaultToolProtocol for DeepSeek R1 mode.
Related GitHub Issue
Closes: #9744
Roo Code Task Context (Optional)
N/A
Description
This PR adds native tool calling support for the
deepseek-reasonermodel in thinking mode, as per the DeepSeek API documentation.Key implementation details:
Override
createMessageinDeepSeekHandler: When usingdeepseek-reasonerwithnativetool protocol, useconvertToOpenAiMessagesinstead ofconvertToR1Formatto properly handle:tool_callsin assistant messagesrole: "tool"messages withtool_call_idfor tool resultsCreate dedicated OpenAI client: Since the parent class's
clientisprivate, a separatedeepSeekClientis created inDeepSeekHandlerfor native tool calling requests.Delegation pattern: For all other cases (XML protocol or
deepseek-chatmodel), the implementation delegates to the parent class to maintain backward compatibility.Why this change is needed:
The existing
convertToR1Formatfunction only handlestextandimagemessage types, but doesn't processtool_useandtool_resultblocks required for native tool calling. This causes issues when usingdeepseek-reasonerwith native tools enabled.Test Procedure
deepseek-reasonermodelnativein the profile settingsreasoning_content(thinking chain) is still captured and displayedPre-Submission Checklist
Screenshots / Videos
N/A - This is a backend/API change with no UI impact.
Documentation Updates
Additional Notes
deepseek-reasoner+nativeprotocol combinationGet in Touch
haha.w
Important
Adds native tool calling support for
deepseek-reasonerinDeepSeekHandlerby overridingcreateMessageand creating a dedicated OpenAI client.createMessageinDeepSeekHandlerto supportdeepseek-reasonerwithnativetool protocol usingconvertToOpenAiMessages.tool_callsandrole: "tool"messages withtool_call_id.deepSeekClientinDeepSeekHandlerfor native tool calling requests.XmlMatcherto process reasoning content and tool calls.processUsageMetricsto handle DeepSeek's usage metrics.This description was created by
for 5839260. You can customize this summary. It will automatically update as commits are pushed.