feat(providers): native DeepSeek V4 Flash adapter via official API - #282
Open
qpdv (qpd-v) wants to merge 1 commit into
Open
feat(providers): native DeepSeek V4 Flash adapter via official API#282qpdv (qpd-v) wants to merge 1 commit into
qpdv (qpd-v) wants to merge 1 commit into
Conversation
DeepSeek was routed through the generic OpenAI-compatible adapter, which mishandled V4's reasoning and strict tool-schema validation. Add a native @ai-sdk/deepseek adapter and the supporting plumbing: - Resolve the native adapter for the deepseek provider in both npm-resolution chains (models.dev ingestion + config-provider merge), so deepseek-v4 models use the V2-spec adapter that replays reasoning_content across tool loops. - Add a deepseek CUSTOM_LOADER that pins the official endpoint (https://api.deepseek.com), honors DEEPSEEK_BASE_URL, and resolves the key from auth.json or DEEPSEEK_API_KEY. - Direct-provider-beats-OpenRouter: when the configured model is an OpenRouter slug for a vendor that also has a direct BYOK provider with the same model (date-suffix tolerant), prefer the official API route over the relay. - Normalize tool schemas at the provider boundary for DeepSeek/OpenAI- compatible gateways: flatten zod discriminated-union oneOf shapes into a plain type:"object" and strip constraint keywords their strict validators reject (fixes HTTP 400 "schema must be of type object" on compute_job). - Flatten the compute_job tool contract to a plain object schema and gate job_id at runtime, matching the normalized wire shape. - DeepSeek-v4 thinking control: non-reasoning v4 models get thinking:{type:"disabled"} so agent calls don't silently reason; small calls (titles/summaries/compaction) disable thinking on the flash model; variants expose low/medium/high/max reasoningEffort. Tests: deepseek resolution (native adapter, base URL override, direct-beats- OpenRouter incl. unauthenticated shadow guard, small_model routing), tool-schema normalization, and transform variants/options/smallOptions. Full CLI suite shows no regressions vs baseline. Co-Authored-By: Claude <noreply@anthropic.com>
|
qpdv (@qpd-v) is attempting to deploy a commit to the InkVell Team on Vercel. A member of the Team first needs to authorize it. |
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
Adds a native DeepSeek adapter via the official API (
https://api.deepseek.com), sodeepseek-v4-*models work end-to-end without being routed through the generic OpenAI-compatible adapter (which mishandles V4's reasoning and strict tool-schema validation).What changed
deepseekprovider now resolves to@ai-sdk/deepseekin both npm-resolution chains (models.dev ingestion + config-provider merge). The V2-spec adapter replaysreasoning_contentacross tool loops and exposesthinking/reasoningEffort/strictJsonSchema.deepseekcustom loader that pinshttps://api.deepseek.com, honorsDEEPSEEK_BASE_URL, and resolves the key fromopenscience keys add deepseek(auth.json) orDEEPSEEK_API_KEY.deepseek/deepseek-v4-flashvsdeepseek/deepseek-v4-flash:free), requests route straight to the official API instead of the relay.oneOfshapes become a plaintype:"object", and constraint keywords their strict validators reject (minimum,pattern,minLength, …) are stripped. Fixes HTTP 400Invalid schema for function 'compute_job'.compute_jobcontract flattened. The tool's schema is now a plain object schema withjob_idgated at runtime.thinking:{type:"disabled"}; small calls (titles/summaries/compaction) disable thinking; variants exposelow/medium/high/maxviareasoningEffort.Tests
Added
deepseek.test.ts(resolution, base URL override, direct-beats-OpenRouter incl. unauthenticated shadow guard, small_model routing),tool-schema.test.ts, andtransform-deepseek.test.ts. Full CLI suite: no regressions vs baseline (1734 pass vs 1704 baseline; the remaining failures are pre-existing Windows sandbox/teardown flakiness).Notes
@ai-sdk/deepseek@1.0.50(the last V2-language-model-spec version, compatible withai@5.0.119; the 3.x line targets the V4 spec and is incompatible).ping→pong 🏓over the direct route, and a tool-loop session (glob) with no schema 400s.