feat(qwen): migrate Qwen provider to AI SDK#11190
Closed
daniel-lxs wants to merge 1 commit intomainfrom
Closed
Conversation
- Replace direct OpenAI SDK usage with @ai-sdk/openai-compatible - Use streamText and generateText from ai package for streaming/completion - Integrate shared transform utilities for message/tool conversion - Maintain OAuth credential management with automatic token refresh - Update tests to use AI SDK mocking patterns Resolves EXT-712
Contributor
Review complete. Found 1 issue to address:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| } | ||
| } catch (error: any) { | ||
| // Handle 401 errors by refreshing token and retrying once | ||
| if (error?.statusCode === 401 || error?.response?.status === 401) { |
Contributor
There was a problem hiding this comment.
The 401 error detection may not work correctly with AI SDK errors. AI_APICallError uses .status as its primary property, and AI_RetryError exposes it via .lastError?.status. The current check only looks at .statusCode and .response?.status, which means token refresh may not trigger when the API returns 401.
Suggested change
| if (error?.statusCode === 401 || error?.response?.status === 401) { | |
| if (error?.status === 401 || error?.statusCode === 401 || error?.response?.status === 401) { |
The same pattern applies to the completePrompt method at line 347.
Fix it with Roo Code or mention @roomote and request a fix.
Member
Author
|
This is Qwen Code not Qwen itself |
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.
Summary
Migrates the Qwen Code provider to use the Vercel AI SDK (
@ai-sdk/openai-compatible) instead of the direct OpenAI SDK.Changes
src/api/providers/qwen-code.ts@ai-sdk/openai-compatible'screateOpenAICompatiblestreamTextandgenerateTextfrom theaipackage for streaming and completionconvertToAiSdkMessages,convertToolsForAiSdk,processAiSdkStreamPart,mapToolChoice)getModelParamsintegration for proper model parameter handlingsrc/api/providers/__tests__/qwen-code-native-tools.spec.tsmockStreamText,mockGenerateText)@ai-sdk/openai-compatible'screateOpenAICompatibletool-input-start,tool-input-delta,tool-input-end,reasoning)Benefits
Testing
Resolves EXT-712
Important
Migrates Qwen Code provider to Vercel AI SDK, updating message handling, tool integration, and OAuth management.
qwen-code.tsto use Vercel AI SDK (@ai-sdk/openai-compatible) instead of OpenAI SDK.streamTextandgenerateTextfor streaming and completion.getModelParamsfor model parameter handling.qwen-code-native-tools.spec.tsto use AI SDK mocking patterns (mockStreamText,mockGenerateText).createOpenAICompatible.tool-input-start,tool-input-delta,tool-input-end,reasoning).This description was created by
for f9c432e. You can customize this summary. It will automatically update as commits are pushed.