Skip to content

.Net: Bug: Inconsistent usage of JsonSerializer options #11714

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

Open
Ilia-Kosenkov opened this issue Apr 24, 2025 · 0 comments
Open

.Net: Bug: Inconsistent usage of JsonSerializer options #11714

Ilia-Kosenkov opened this issue Apr 24, 2025 · 0 comments
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code

Comments

@Ilia-Kosenkov
Copy link

Ilia-Kosenkov commented Apr 24, 2025

Hi! I am exploring semantic kernel and was looking into specifying JSON serialization options for my plugins. I stumbled upon this doc https://github.com/microsoft/semantic-kernel/blob/main/docs/decisions/0060-jsos-integration.md and followed it. However, I observed that the tool call results in chat history are serialized with some default behavior different from what I expect. I debugged deep into the framework and found that the function result is serialized here with the default JSON configuration. Which AFAIK I cannot influence.

return JsonSerializer.Serialize(functionResult, s_functionResultSerializerOptions);
}
/// <summary>
/// The <see cref="JsonSerializerOptions" /> which will be used in <see cref="ProcessFunctionResult(object)"/>.
/// </summary>
/// <remarks>
/// <see cref="JsonSerializer.Serialize{TValue}(TValue, JsonSerializerOptions?)"/> is very likely to escape characters and generates LLM unfriendly results by default.
/// </remarks>
private static readonly JsonSerializerOptions s_functionResultSerializerOptions = new()
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
};
}

Are there any plans to allow configuration of this options as well? Can it affect chained tool calls when using a history object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code
Projects
Status: Bug
Development

No branches or pull requests

3 participants