Fix serialization of OpenAIPromptExecutionSettings with System.Type in ResponseFormat#13116
Open
shethaadit wants to merge 5 commits into
Open
Fix serialization of OpenAIPromptExecutionSettings with System.Type in ResponseFormat#13116shethaadit wants to merge 5 commits into
OpenAIPromptExecutionSettings with System.Type in ResponseFormat#13116shethaadit wants to merge 5 commits into
Conversation
OpenAIPromptExecutionSettings with System.Type in ResponseFormatOpenAIPromptExecutionSettings with System.Type in ResponseFormat
OpenAIPromptExecutionSettings with System.Type in ResponseFormatOpenAIPromptExecutionSettings with System.Type in ResponseFormat
rogerbarreto
approved these changes
Sep 15, 2025
Contributor
|
@shethaadit can you take a look at the unit test failure |
Contributor
Author
Hi @markwallace-microsoft, I fixed it and made some code change. Could you please review again? |
Contributor
Author
|
Hi @markwallace-microsoft, @rogerbarreto, could you please help reviewing again? |
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.
Description:
This pull request addresses a serialization issue where setting the
ResponseFormatproperty ofOpenAIPromptExecutionSettingsto aSystem.Typewould cause aSystem.NotSupportedExceptionduring JSON serialization. This was due toSystem.Typenot being inherently JSON serializable, which broke scenarios that rely on serializing prompt execution settings.To resolve this, a custom
JsonConverter(TypeOrFunctionResponseFormatConverter) has been introduced. This converter interceptsSystem.Typeobjects during serialization and correctly transforms them into the JSON schema format expected by the OpenAI API.Changes:
TypeOrFunctionResponseFormatConverter.csto handle the custom serialization logic forSystem.Type.ResponseFormatproperty inOpenAIPromptExecutionSettings.cs.OpenAIPromptExecutionSettingsTests.csto verify that serialization now works as expected without throwing an exception.Validation:
The included unit test,
ItCanSerializeResponseFormatAsType, now passes, confirming that theOpenAIPromptExecutionSettingscan be successfully serialized whenResponseFormatis aSystem.Type.Issue:
Fixes #13107