Skip to content

.NET: Fix the ordering of chained resolvers in JsonSerializerOptions - #1974

Merged
Stephen Toub (stephentoub) merged 5 commits into
microsoft:mainfrom
stephentoub:fixjsonordering
Nov 6, 2025
Merged

Stephen Toub (stephentoub) merged 5 commits into
microsoft:mainfrom
stephentoub:fixjsonordering

Conversation

@stephentoub

@stephentoub Stephen Toub (stephentoub) commented Nov 6, 2025

Copy link
Copy Markdown
Member

We want the resolvers from AIJsonUtilities to be used before the ones from the source generator, in case the source generator emits its own copy in that assembly for the M.E.AI types.o the title of the PR.

Fixes #1318

We want the resolvers from AIJsonUtilities to be used before the ones from the source generator, in case the source generator emits its own copy in that assembly for the M.E.AI types.
Copilot AI review requested due to automatic review settings November 6, 2025 19:18
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Nov 6, 2025
@github-actions github-actions Bot changed the title Fix the ordering of chained resolvers in JsonSerializerOptions .NET: Fix the ordering of chained resolvers in JsonSerializerOptions Nov 6, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request standardizes the JSON serialization configuration across multiple JSON utility classes and adds test coverage for experimental content types in serialization.

  • Implements a consistent pattern for TypeInfoResolverChain configuration across all JSON utility classes by explicitly clearing and rebuilding the resolver chain
  • Ensures proper ordering of type resolvers with base library resolvers (AIJsonUtilities or AgentAbstractionsJsonUtilities) taking precedence over source-generated contexts
  • Adds test coverage for serialization/deserialization of experimental content types (FunctionApprovalRequestContent and FunctionApprovalResponseContent)

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/InMemoryChatMessageStoreTests.cs Adds test case validating serialization round-trip for experimental function approval content types
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentAbstractionsJsonUtilities.cs Standardizes resolver chain setup by explicitly clearing and adding AIJsonUtilities resolver before local context
dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.cs Applies same resolver chain pattern with AgentAbstractionsJsonUtilities resolver taking precedence
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowsJsonUtilities.cs Applies consistent resolver chain configuration pattern
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0JsonUtilities.cs Applies consistent resolver chain configuration pattern
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs Applies consistent resolver chain configuration pattern
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/ChatCompletions/ChatCompletionsJsonSerializerOptions.cs Applies consistent resolver chain configuration pattern

Comment thread dotnet/src/Microsoft.Agents.AI.Mem0/Mem0JsonUtilities.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@stephentoub

Copy link
Copy Markdown
Member Author

Comment thread dotnet/src/Microsoft.Agents.AI.Mem0/Mem0JsonUtilities.cs Outdated
Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
Comment thread dotnet/src/Microsoft.Agents.AI.Mem0/Mem0JsonUtilities.cs Outdated
Removed unused using directive for Microsoft.Extensions.AI.
@stephentoub
Stephen Toub (stephentoub) added this pull request to the merge queue Nov 6, 2025
Merged via the queue into microsoft:main with commit 820c6af Nov 6, 2025
14 checks passed
@stephentoub
Stephen Toub (stephentoub) deleted the fixjsonordering branch November 7, 2025 13:22
Aris Nguyen (arisng) pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
…icrosoft#1974)

* Fix the ordering of chained resolvers in JsonSerializerOptions

We want the resolvers from AIJsonUtilities to be used before the ones from the source generator, in case the source generator emits its own copy in that assembly for the M.E.AI types.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.cs

* Update dotnet/src/Microsoft.Agents.AI.Mem0/Mem0JsonUtilities.cs

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>

* Remove unused using directive in Mem0JsonUtilities

Removed unused using directive for Microsoft.Extensions.AI.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Bug Report: Cannot Serialize AgentThread with FunctionApprovalRequestContent

5 participants