Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 2, 2025

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

  • ✨ Add supportsNativeTools flag to qwen3-coder-plus and qwen3-coder-flash models in the type definitions
  • 🔧 Update QwenCodeHandler to accept and pass tools to the underlying OpenAI client when using native tool protocol
  • 📡 Add handling for tool_call_partial chunks in the streaming response to properly relay tool calling information
  • 🔒 Ensure tools are only enabled when toolProtocol is set to "native" (not for XML protocol)
  • ✅ Add comprehensive test coverage for tool calling functionality

Testing

  • All new tests for tool calling functionality pass successfully
  • Existing tests remain unaffected
  • Tool calls are properly forwarded to the OpenAI API only when using native protocol
  • Tool call responses are correctly parsed and yielded as partial chunks

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.

  • Behavior:
    • Add supportsNativeTools flag to qwen3-coder-plus and qwen3-coder-flash models in qwen-code.ts.
    • Update QwenCodeHandler in qwen-code.ts to handle tool calls when toolProtocol is "native".
    • Handle tool_call_partial chunks in streaming responses in qwen-code.ts.
  • Testing:
    • Add tests in qwen-code.spec.ts to verify tool call functionality, including tool inclusion, tool choice, and parallel tool calls.
    • Ensure tools are not included when toolProtocol is not "native".
  • Misc:
    • Follow pattern of other OpenAI-compatible providers for consistency.

This description was created by Ellipsis for 7b6be8c. You can customize this summary. It will automatically update as commits are pushed.

- 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
@roomote roomote bot requested review from cte, jr and mrubens as code owners December 2, 2025 23:21
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Dec 2, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Dec 2, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. Found 1 issue that should be addressed:

  • Tool calling implementation differs from other OpenAI-compatible providers - tools and tool_choice should be included whenever they exist in metadata, not gated by protocol

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +227 to +238
// 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,
}),
Copy link
Contributor Author

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Reactivate "Tool Call" for Qwen Code provider

3 participants