fix: Azure DeepSeek structured output returns JSON in reasoning with empty text - #17244
Merged
R-Taneja merged 1 commit intoJul 14, 2026
Conversation
R-Taneja
force-pushed
the
rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning
branch
from
July 14, 2026 19:01
a79d40b to
20a5669
Compare
shaper
approved these changes
Jul 14, 2026
R-Taneja
deleted the
rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning
branch
July 14, 2026 20:10
Contributor
|
|
Contributor
|
🚀 Published in:
|
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.
Background
A gateway customer reported that structured-output calls to
deepseek/deepseek-v4-flashon Azure fail withNoObjectGeneratedErrorin ~34% of calls: the response is HTTP 200 with valid JSON, but the JSON is entirely inreasoningandtextis empty. Direct Azure calls and Fireworks-served calls for the same model do not fail.Root cause:
DeepSeekChatLanguageModeldowngradesresponseFormat: jsontoresponse_format: {type: 'json_object'}with the schema injected into a system message. Whenreasoning_effortis also set, the Azure DeepSeek deployment misattributes the constrained JSON output toreasoning_contentand returns emptycontent. Verified by direct-to-Azure A/B with otherwise identical request bodies:json_object+ reasoning → 0/3 responses with text (one echoed the input messages into reasoning),json_schema+ reasoning → 3/3 with proper reasoning and the JSON incontent.Summary
supportsStructuredOutputstoDeepSeekChatConfig. When enabled and a schema is present, send an OpenAI-shapedjson_schemaresponse format (strictdefaults to true, newstrictJsonSchemaprovider option) and skip the system-message schema injection and its compatibility warning.azure.deepseek(). The native DeepSeek API path is unchanged and keepsjson_object.Manual Verification
reasoning: 'high'viaazure.deepseek('deepseek-v4-flash')against a real Azure deployment with this fix: reasoning and structured output are both returned correctly.response_format).@ai-sdk/azure+@ai-sdk/deepseekpackages into a local AI Gateway checkout: a repro that fails 4/4 against the production gateway passes 4/4 against the local gateway running this fix.Checklist
pnpm changesetin the project root)Future Work
@ai-sdk/azure@2.x/3.x+@ai-sdk/deepseek@1.x/2.xlines used by older gateway protocol versions.