.NET: Fix the ordering of chained resolvers in JsonSerializerOptions - #1974
Merged
Stephen Toub (stephentoub) merged 5 commits intoNov 6, 2025
Merged
Conversation
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.
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 19:19 — with
GitHub Actions
Inactive
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 19:19 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
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 |
westey (westey-m)
approved these changes
Nov 6, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Stephen Toub (stephentoub)
had a problem deploying
to
integration
November 6, 2025 19:30 — with
GitHub Actions
Error
Stephen Toub (stephentoub)
had a problem deploying
to
integration
November 6, 2025 19:30 — with
GitHub Actions
Failure
Stephen Toub (stephentoub)
had a problem deploying
to
integration
November 6, 2025 19:36 — with
GitHub Actions
Failure
Stephen Toub (stephentoub)
had a problem deploying
to
integration
November 6, 2025 19:36 — with
GitHub Actions
Failure
Stephen Toub (stephentoub)
enabled auto-merge
November 6, 2025 19:36
Stephen Toub (stephentoub)
requested a review
from Roger Barreto (rogerbarreto)
November 6, 2025 19:36
Member
Author
Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 19:58 — with
GitHub Actions
Inactive
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 19:58 — with
GitHub Actions
Inactive
Removed unused using directive for Microsoft.Extensions.AI.
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 22:10 — with
GitHub Actions
Inactive
Stephen Toub (stephentoub)
temporarily deployed
to
integration
November 6, 2025 22:10 — with
GitHub Actions
Inactive
SergeyMenshykh
approved these changes
Nov 6, 2025
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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