refactor: migrate Qwen Code provider to AI SDK #11356
Merged
+470
−483
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 (
QwenCodeHandler) from manual OpenAI SDK streaming to the Vercel AI SDK viaOpenAICompatibleHandler(Archetype 1 migration perplans/ai-sdk-migration-guide.md).Changes
BaseProvider→OpenAICompatibleHandlerusing@ai-sdk/openai-compatiblestreamText()+processAiSdkStreamPart()<think>tag parsing →extractReasoningMiddleware({ tagName: "think" })NativeToolCallParser+ manual deltas → AI SDK native tool handlingconvertToOpenAiMessages→convertToAiSdkMessageshandleAiSdkError()getLanguageModel()creates fresh provider with current OAuth credentials per request;createMessage()andcompletePrompt()both include 401 retryisAiSdkProvider(): Returnstrue(inherited fromOpenAICompatibleHandler)Breaking Change Audit
All potential breaking changes were investigated and resolved:
isAiSdkProvider()flips trueincludeUsagenot explicit@ai-sdk/openai-compatiblehandles internallyRemoved Dependencies (from this file)
openaiSDK direct usageconvertToOpenAiMessagesfromopenai-format.ts(reduces consumer count from 8 → 7)NativeToolCallParserimportImportant
Refactor Qwen Code provider to use Vercel AI SDK, updating OAuth handling and tests.
QwenCodeHandlerto extendOpenAICompatibleHandlerusing Vercel AI SDK.streamText()andprocessAiSdkStreamPart().extractReasoningMiddlewarefor reasoning tag parsing.NativeToolCallParserwith AI SDK native tool handling.convertToAiSdkMessages.handleAiSdkError().qwen-code.ts.forceRefreshAndAuthenticate()for token refresh.safeWriteJsonfor saving refreshed credentials.qwen-code-native-tools.spec.tsto mock AI SDK instead of OpenAI SDK.openaiSDK usage.convertToOpenAiMessagesdependency.This description was created by
for c784551. You can customize this summary. It will automatically update as commits are pushed.