.Net: Adding to SerializerOptions property to Kernel
Motivation and Context
Today, SK has several locations where serialization/deserialization takes place. In almost all of these places, it is not possible to control the serialization/deserialization process via JsonSerializerOptions, as there is no way to pass the options to these locations. This PR addresses the issue by adding a SerializerOptions property to the Kernel class, allowing it to be used to control serialization/deserialization wherever the kernel is available.
Description
- Adds the SerializerOptions property to the Kernel class.
- Obsoletes the ToolCallBehavior.ToolCallResultSerializerOptions that was originally introduced to serialize function results.
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines and the pre-submission formatting script raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
@stephentoub , we have the JsonOptionsCache cache, which is used by many SK components. I think it should be removed in favor of the Kernel.SerializerOptions property. The configuration of the cache can be moved to the kernel class and applied as the default one, and all components can be updated to use the Kernel.SerializerOptions instead. What do you think?
@eiriktsarpalis what would be your recommendations in case some SK components need a slight deviation from the default options represented by Kernel.SerializerOptions property?
Is there any ETA about this PR?
Closing this for now this issue will be handled via: .Net: Support of JsonSerializerSettings in SK · Issue #5867 · microsoft/semantic-kernel (github.com)
Please comment on the above issue if you need this to be prioritised.