-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: enable Tool Call support for Qwen Code provider #9762
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?
Conversation
- Add supportsNativeTools flag to qwen3-coder-plus and qwen3-coder-flash models - Update QwenCodeHandler to accept and pass tools to OpenAI client - Add handling for tool_call_partial chunks in streaming response - Only enable tools when toolProtocol is "native" - Add comprehensive test coverage for tool calling functionality Fixes #9761
Review complete. Found 1 issue that should be addressed:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Add tools support only for native protocol | ||
| ...(metadata?.toolProtocol === "native" && | ||
| metadata?.tools && { | ||
| tools: this.convertToolsForOpenAI(metadata.tools), | ||
| }), | ||
| ...(metadata?.toolProtocol === "native" && | ||
| metadata?.tool_choice && { | ||
| tool_choice: metadata.tool_choice, | ||
| }), | ||
| ...(metadata?.toolProtocol === "native" && { | ||
| parallel_tool_calls: metadata.parallelToolCalls ?? false, | ||
| }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool calling implementation differs from other OpenAI-compatible providers in the codebase. In openai.ts:167 and base-openai-compatible-provider.ts:94-98, tools and tool_choice are included whenever they exist in metadata, regardless of protocol. Only parallel_tool_calls is gated by the native protocol check. This implementation gates all three parameters by protocol, which may prevent tool calling from working in certain scenarios where other providers would support it.
Fix it with Roo Code or mention @roomote and request a fix.
This PR attempts to address Issue #9761. Feedback and guidance are welcome.
Summary
This PR reactivates Tool Call functionality for the Qwen Code provider, allowing it to work with function calling similar to other OpenAI-compatible providers in the codebase.
Changes
supportsNativeToolsflag toqwen3-coder-plusandqwen3-coder-flashmodels in the type definitionsQwenCodeHandlerto accept and pass tools to the underlying OpenAI client when using native tool protocoltool_call_partialchunks in the streaming response to properly relay tool calling informationtoolProtocolis set to "native" (not for XML protocol)Testing
Related Issues
Fixes #9761
Notes
The implementation follows the same pattern as other OpenAI-compatible providers in the codebase (e.g.,
OpenAiHandler,BaseOpenAiCompatibleProvider) to ensure consistency.Important
Enable tool call support for Qwen Code provider with native protocol handling and comprehensive tests.
supportsNativeToolsflag toqwen3-coder-plusandqwen3-coder-flashmodels inqwen-code.ts.QwenCodeHandlerinqwen-code.tsto handle tool calls whentoolProtocolis "native".tool_call_partialchunks in streaming responses inqwen-code.ts.qwen-code.spec.tsto verify tool call functionality, including tool inclusion, tool choice, and parallel tool calls.toolProtocolis not "native".This description was created by
for 7b6be8c. You can customize this summary. It will automatically update as commits are pushed.