fix(provider): select DeepSeek adapter for Azure deployments - #44179
fix(provider): select DeepSeek adapter for Azure deployments#44179Shalin-Shah-2002 wants to merge 2 commits into
Conversation
Azure DeepSeek deployments (deepseek-v4-pro, deepseek-v4-flash) currently route through the generic chat or responses adapter, so reasoning effort variants such as max fail and reasoning_content is not preserved across agentic turns. @ai-sdk/azure exposes a DeepSeek-specific adapter that handles these semantics, but it was never selected. Prefer sdk.deepseek() for deployment names containing deepseek in both the V2 provider plugin and the legacy provider loader, while keeping explicit routing overrides for non-DeepSeek deployments. Also emit a max reasoning effort variant for azure deepseek-v4 models. Closes anomalyco#43106
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #43135: This appears to be addressing the exact same issue as the current PR #44179. Both PRs are fixing the same problem: selecting the DeepSeek adapter for Azure deployments. Since the current PR also closes issue #43106, PR #43135 likely addresses the same issue or is an earlier attempt at the same fix. |
Reviewed the full diff (6 files). Overall this is a clean fix with unusually good test coverage — positive path, 1. Confirm the pinned 2. Two different predicates for "is DeepSeek" in one PR — the selectors match 3. Duplicated selector logic across packages — the same 4-line guard + comment block now exists verbatim in both 4. Minor: duplicate-key safety in None of these block the approach — the fallback test in particular means worst-case behavior degrades to the status quo. |
Add cross-package keep-in-sync comments for the duplicated selector and note why the adapter gate (any deepseek deployment) deliberately differs from the max-effort variant gate (deepseek-v4 only). Harden the azure variants push against a duplicate max key.
|
Thanks for the review. Addressed points 2-4 in commit 9926e46; evidence for point 1 below. 1. Real SDK confirmation — the integration test in 2. Predicate difference — intentional: adapter selection matches any 3. Duplication — added 4. Duplicate max — hardened: |
Issue for this PR
Closes #43106
Type of change
What does this PR do?
Azure-hosted
DeepSeek-V4-Pro/DeepSeek-V4-Flashdeployments currently route through the generic chat or responses adapter in both the V2 provider plugin (packages/core/src/plugin/provider/azure.ts) and the legacy loader (packages/opencode/src/provider/provider.ts). The bundled@ai-sdk/azureprovider exposessdk.deepseek(), which handles DeepSeek Chat Completions semantics —max_tokens,reasoning_effort(low/medium/high/xhigh/max), andreasoning_contentacross reasoning/tool-call turns. It was never selected, soreasoningEffort: maxvariants failed with a generic Azure error.Changes:
packages/core/src/plugin/provider/azure.tsandpackages/opencode/src/provider/provider.ts: prefersdk.deepseek(modelID)for deployment names containingdeepseek, before theuseCompletionUrls/responses routing (the DeepSeek adapter is chat-completions based, so it also applies when completion URLs are used). Explicit routing overrides for non-DeepSeek deployments are unchanged.packages/opencode/src/provider/transform.ts: azurereasoningVariantsnow emits amaxeffort variant fordeepseek-v4deployments (mirrors the existing@ai-sdk/openai-compatiblebehavior), soazure/deepseek-v4-pro:maxexists.@ai-sdk/azureSDK (assertingazure.deepseekprovider, plus unchangedresponses/chatrouting for non-DeepSeek models), variant generation, and the V2 plugin selector with a fake SDK.How did you verify your code works?
bun typecheckinpackages/coreandpackages/opencode— clean.bun test test/provider/provider.test.ts test/provider/transform.test.tsinpackages/opencode— 518 pass; the single failure (Google Vertex: uses REP endpoint for Gemini continental multi-regions) also fails on cleandevand is unrelated.packages/core/test/plugin/provider-azure.test.tscannot load in this environment due to a pre-existing circular import (plugin/provider.ts↔plugin/internal.ts) that fails on cleandevtoo; the new core tests follow the existing pattern exactly and the core package typechecks.Screenshots / recordings
N/A
Checklist