Skip to content

.Net: Fix #10389 - #10406

Merged
Mark Wallace (markwallace-microsoft) merged 5 commits into
microsoft:mainfrom
RamType0:fix-function-result-serialization
Feb 10, 2025
Merged

.Net: Fix #10389#10406
Mark Wallace (markwallace-microsoft) merged 5 commits into
microsoft:mainfrom
RamType0:fix-function-result-serialization

Conversation

@RamType0

Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes issue #10389.

Description

Use JsonSerializerOptions.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping to generate more LLM friendly serialized FunctionResult.

Contribution Checklist

Use `JsonSerializerOptions.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping`
@RamType0
Ram.Type-0 (RamType0) requested a review from a team as a code ownerFebruary 5, 2025 02:40
@markwallace-microsoftMark Wallace (markwallace-microsoft) added the .NET Issue or Pull requests regarding .NET code label Feb 5, 2025
@github-actionsgithub-actionsBot changed the title Fix #10389.Net: Fix #10389Feb 5, 2025
@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Hi Ram.Type-0 (@RamType0), thanks for submitting the PR. We are evaluating the fix along with an alternative solution that would allow for customizing the function result serialization process. Please bear with us; it shouldn't take long.

dmytrostruk

This comment was marked as outdated.

@RamType0

Copy link
Copy Markdown
ContributorAuthor

Ram.Type-0 (@RamType0) Thanks for your contribution!

I'm not sure if this solution will work since this encoder may impact the serialization for other users in unpredictable way. Here is more information: image

Why you think that we will use the function result for HTML rendering directly?

I could not imagine that scenario.

In ideal scenario, users should be able to provide their custom JsonSerializerOptions which will be used for {de}serialization through the entire Semantic Kernel flow. We know that it's not possible today and we may work on it to add this feature in the future.

Customization feature is good, but I think this should be the default behavior.

Many alphabet speaker programmers previously made many bugs with multi byte characters.
And today, they will made that kind of bugs with this library again.

@dmytrostruk

Copy link
Copy Markdown
Member

Ram.Type-0 (@RamType0) Thanks for your response! My comment is outdated now, SergeyMenshykh will provide more details soon.

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Hi Ram.Type-0 (@RamType0), we plan to proceed with merging this PR, but before that, please cover the change with unit test(s).

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Linking this PR to the M.E.AI one: Use unsafe relaxed escaping in AIJsonUtilities.DefaultOptions as both address the same issue

@markwallace-microsoftMark Wallace (markwallace-microsoft) added the kernel Issues or pull requests impacting the core kernel label Feb 7, 2025
@RamType0

Copy link
Copy Markdown
ContributorAuthor

@microsoft-github-policy-service agree

@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queueFeb 7, 2025
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Feb 7, 2025
Merged via the queue into microsoft:main with commit 018c014Feb 10, 2025
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
### Motivation and Context
Fixes issue microsoft#10389.
### Description
Use `JsonSerializerOptions.Encoder =
JavaScriptEncoder.UnsafeRelaxedJsonEscaping` to generate more LLM
friendly serialized FunctionResult.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernelIssues or pull requests impacting the core kernel.NETIssue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@RamType0@SergeyMenshykh@dmytrostruk@markwallace-microsoft