Skip to content

fix: Azure DeepSeek structured output returns JSON in reasoning with empty text - #17244

Merged
R-Taneja merged 1 commit into
mainfrom
rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning
Jul 14, 2026
Merged

fix: Azure DeepSeek structured output returns JSON in reasoning with empty text#17244
R-Taneja merged 1 commit into
mainfrom
rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning

Conversation

@R-Taneja

@R-Taneja R-Taneja commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Background

A gateway customer reported that structured-output calls to deepseek/deepseek-v4-flash on Azure fail with NoObjectGeneratedError in ~34% of calls: the response is HTTP 200 with valid JSON, but the JSON is entirely in reasoning and text is empty. Direct Azure calls and Fireworks-served calls for the same model do not fail.

Root cause: DeepSeekChatLanguageModel downgrades responseFormat: json to response_format: {type: 'json_object'} with the schema injected into a system message. When reasoning_effort is also set, the Azure DeepSeek deployment misattributes the constrained JSON output to reasoning_content and returns empty content. 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 in content.

Summary

  • Add supportsStructuredOutputs to DeepSeekChatConfig. When enabled and a schema is present, send an OpenAI-shaped json_schema response format (strict defaults to true, new strictJsonSchema provider option) and skip the system-message schema injection and its compatibility warning.
  • Enable the flag in azure.deepseek(). The native DeepSeek API path is unchanged and keeps json_object.

Manual Verification

  • Ran a structured-output request with reasoning: 'high' via azure.deepseek('deepseek-v4-flash') against a real Azure deployment with this fix: reasoning and structured output are both returned correctly.
  • Direct-to-Azure A/B described above (0/3 → 3/3 with identical bodies except response_format).
  • Linked the built @ai-sdk/azure + @ai-sdk/deepseek packages 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

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

  • Backport to the @ai-sdk/azure@2.x/3.x + @ai-sdk/deepseek@1.x/2.x lines used by older gateway protocol versions.

@R-Taneja R-Taneja added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jul 14, 2026
@R-Taneja
R-Taneja requested a review from shaper July 14, 2026 19:00
@R-Taneja
R-Taneja force-pushed the rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning branch from a79d40b to 20a5669 Compare July 14, 2026 19:01
@R-Taneja
R-Taneja merged commit 49ae04d into main Jul 14, 2026
49 checks passed
@R-Taneja
R-Taneja deleted the rohantaneja/aig-157-azure-deepseek-structured-output-returns-json-in-reasoning branch July 14, 2026 20:10
github-actions Bot added a commit that referenced this pull request Jul 14, 2026
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Backport to release-v6.0 created but has conflicts: #17250

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.28 github npm
@ai-sdk/amazon-bedrock 5.0.22 github npm
@ai-sdk/angular 3.0.28 github npm
@ai-sdk/azure 4.0.15 github npm
@ai-sdk/deepseek 3.0.11 github npm
@ai-sdk/google 4.0.16 github npm
@ai-sdk/google-vertex 5.0.20 github npm
@ai-sdk/harness 1.0.33 github npm
@ai-sdk/harness-claude-code 1.0.34 github npm
@ai-sdk/harness-codex 1.0.35 github npm
@ai-sdk/harness-deepagents 1.0.32 github npm
@ai-sdk/harness-opencode 1.0.34 github npm
@ai-sdk/harness-pi 1.0.33 github npm
@ai-sdk/langchain 3.0.28 github npm
@ai-sdk/llamaindex 3.0.28 github npm
@ai-sdk/otel 1.0.28 github npm
@ai-sdk/policy-opa 1.0.28 github npm
@ai-sdk/react 4.0.30 github npm
@ai-sdk/rsc 3.0.28 github npm
@ai-sdk/sandbox-just-bash 1.0.33 github npm
@ai-sdk/sandbox-vercel 1.0.33 github npm
@ai-sdk/svelte 5.0.28 github npm
@ai-sdk/tui 1.0.28 github npm
@ai-sdk/vue 4.0.28 github npm
@ai-sdk/workflow 1.0.28 github npm
@ai-sdk/workflow-harness 1.0.33 github npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants