semantic-kernel
semantic-kernel copied to clipboard
Updates and tests for plan serialization and deserialization
Motivation and Context
The change improves the serialization and deserialization of Plan objects.
Description
Allows deserialization of Plans without a context. Adds unit tests for the Plan and ContextVariables classes, which cover various scenarios and edge cases of serializing and deserializing plans and context variables.
Details:
- Updates the custom converter for the ContextVariables class, which serializes and deserializes the key-value pairs as an array of objects, instead of a dictionary. This improves the efficiency and readability of the JSON format.
- Add a new file PlanSerializationTests.cs to the SemanticKernel.UnitTests project, which contains unit tests for the Plan class. The tests verify that a plan can be serialized and deserialized correctly, and that the plan state is updated correctly after each step execution. The tests also check for invalid JSON strings.
- Add a new file ContextVariablesConverterTests.cs to the SemanticKernel.UnitTests project, which contains unit tests for the ContextVariablesConverter class. The tests verify that the converter can correctly serialize and deserialize context variables to and from JSON, and handle null, empty, and invalid inputs.
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with
dotnet format - [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile:
Currently holding for #598