-
Notifications
You must be signed in to change notification settings - Fork 849
Workaround OpenAI bug with streaming error events #7085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a workaround for an OpenAI SDK bug where streaming error events are sent in a format different from the documented specification. The OpenAI service embeds error information in a nested error object, but the SDK deserializes it at the top level, causing the properties to be null.
Key changes:
- Added fallback logic to extract error details from raw JSON when SDK deserialization fails
- Added comprehensive test coverage for three error format scenarios: documented format, actual undocumented format, and missing error information
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs | Implements workaround to extract error information from raw JSON Patch when OpenAI SDK fails to deserialize error properties correctly |
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs | Adds three test cases validating error parsing for documented format, undocumented/alternative format, and graceful handling when no error information is present |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs
Show resolved
Hide resolved
|
Thanks a lot for fixing this, looking forward to test it. |
|
Should be Tuesday |
openai/openai-dotnet#849
Closes microsoft/agent-framework#2428
Microsoft Reviewers: Open in CodeFlow