Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Oct 8, 2025

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner October 8, 2025 22:20
@Copilot Copilot AI review requested due to automatic review settings October 8, 2025 22:20
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 8, 2025
@stephentoub
Copy link
Member Author

cc: @westey-m

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes serialization issues with experimental AIContent-derived types by implementing a temporary workaround that registers them for JSON serialization without using the JsonDerivedType attributes.

  • Adds a comprehensive test to verify serialization roundtrips for all AIContent-derived types
  • Implements a temporary workaround to register experimental types for JSON serialization
  • Updates error messages and method signatures to support the workaround approach

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
AIContentTests.cs Adds comprehensive test covering serialization of all AIContent-derived types including experimental ones
AIJsonUtilities.cs Updates method to support bypassing built-in type checks and improves error messages
AIJsonUtilities.Defaults.cs Registers experimental types for serialization and adds them to JsonSerializerContext
AIContent.cs Updates comments explaining the temporary workaround approach

Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some context of what motivated this change?

@stephentoub
Copy link
Member Author

Is there some context of what motivated this change?

Serializing a chat message that contains these types otherwise blows up.

@stephentoub stephentoub merged commit ba9f925 into dotnet:main Oct 9, 2025
7 checks passed
@stephentoub stephentoub deleted the fixserialization branch October 9, 2025 14:18
@abhishek4official
Copy link

Is it released in nuget. If so which version

@stephentoub
Copy link
Member Author

It'll be in a new version on nuget later today.

@stephentoub
Copy link
Member Author

This was referenced Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants