[PR #11204] fix: fix azure open-4o-08-06 when enable json schema cant process content = "" #27118

Closed
opened 2026-02-21 20:40:54 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/11204

State: closed
Merged: Yes


Summary

The bug caused by Azure model changes first occurred on November 18, 2024. When using the Azure OpenAI GPT-4o-08-06 model with JSON schema format output, if a tool is invoked and the assistant message content is an empty string, the model fails to respond properly, ultimately resulting in a 500 error. To ensure compatibility, it is necessary to detect when the assistant message involves a tool invocation and replace an empty message content with None to enable proper responses.

Screenshots

debug wiht azure py code

before:
image
image

after:
image
image

debug with dify backend code:

before:

image

after:

image

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/11204 **State:** closed **Merged:** Yes --- # Summary The bug caused by Azure model changes first occurred on November 18, 2024. When using the Azure OpenAI GPT-4o-08-06 model with JSON schema format output, if a tool is invoked and the assistant message content is an empty string, the model fails to respond properly, ultimately resulting in a 500 error. To ensure compatibility, it is necessary to detect when the assistant message involves a tool invocation and replace an empty message content with None to enable proper responses. # Screenshots ## debug wiht azure py code before: ![image](https://github.com/user-attachments/assets/9acb8e84-6d52-4fb0-bd82-ae1b58b5ac50) ![image](https://github.com/user-attachments/assets/5ac7bc96-eac6-4fc0-be54-0e526e0406bb) after: ![image](https://github.com/user-attachments/assets/a6b8dd8c-171b-4961-94af-b9ff01a027e3) ![image](https://github.com/user-attachments/assets/67eab7e9-bbc2-41e0-9355-74fe592b7dcc) ## debug with dify backend code: before: <img width="1637" alt="image" src="https://github.com/user-attachments/assets/0e710e91-af6f-47bd-a995-e72bc5051142"> after: <img width="1643" alt="image" src="https://github.com/user-attachments/assets/961098a3-b149-4d4b-925a-40a944b87c03"> # Checklist > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:40:54 -05:00
yindo closed this issue 2026-02-21 20:40:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#27118