Skip to content

.Net: Bug: Custom JsonSerializerOptions passed to kernel plugins are not used. #12532

Open
@ascott18

Description

@ascott18

Describe the bug
Custom JsonSerializerOptions passed to kernel plugins are not used.

To Reproduce
Steps to reproduce the behavior:

  1. Create and use a kernel plugin that was created with custom JSON options:
KernelPluginFactory.CreateFromType<PersonKernelPlugin>(
    new JsonSerializerOptions { /* desired custom JSON settings */ },
    "Person"
)
  1. Expect those settings to be used to serialize kernel function results
  2. Observe in the SK source code that this is not the case - instead, a static, immutable, inaccessible set of JSON options are used instead: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/InternalUtilities/connectors/AI/FunctionCalling/FunctionCallsProcessor.cs#L503-L515

Expected behavior
Custom JSON options are used so that my results are serialized as expected according to my customizations (custom converters, null handling, loop handling, etc).

Platform

  • Language: C#
  • Source: NuGet Microsoft.SemanticKernel 1.57.0
  • AI model: N/A
  • IDE: N/A
  • OS: N/A

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions