Conversation
b523382 to
0eca39a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes JSON checkpoint deserialization resilient to out-of-order polymorphic metadata (e.g., $type) so that checkpoints stored in PostgreSQL jsonb (and other sources that reorder properties) can be deserialized successfully.
Changes:
- Extend
JsonMarshallerto respect a newJsonCheckpointManagerOptions.AllowOutOfOrderMetadataPropertiesflag via its internalJsonSerializerOptions. - Introduce
JsonCheckpointManagerOptionsand thread it throughCheckpointManager.CreateJsonso callers can opt into relaxed metadata ordering behavior. - Add targeted unit tests (and a helper) to reproduce the
jsonbmetadata-ordering issue and validate that enabling the new option restores successful deserialization.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs |
Adds regression tests simulating out-of-order $type metadata and verifying default failure vs. success when AllowOutOfOrderMetadataProperties is enabled, plus a helper to reorder JSON properties. |
dotnet/src/Microsoft.Agents.AI.Workflows/Checkpointing/JsonMarshaller.cs |
Updates the marshaller to accept JsonCheckpointManagerOptions and configure AllowOutOfOrderMetadataProperties on its internal JsonSerializerOptions. |
dotnet/src/Microsoft.Agents.AI.Workflows/Checkpointing/JsonCheckpointManagerOptions.cs |
Introduces a public options class with a flag to allow out-of-order metadata properties during JSON deserialization, with XML documentation. |
dotnet/src/Microsoft.Agents.AI.Workflows/CheckpointManager.cs |
Extends CreateJson with an optional JsonCheckpointManagerOptions parameter and passes it to JsonMarshaller so callers can opt in to relaxed metadata ordering. |
0eca39a to
e9da6ec
Compare
e9da6ec to
b3065f8
Compare
westey-m
reviewed
Jan 26, 2026
westey-m
approved these changes
Jan 26, 2026
b3065f8 to
4036b04
Compare
92c9a3e to
8cf4f7d
Compare
SergeyMenshykh
approved these changes
Jan 28, 2026
westey-m
approved these changes
Jan 28, 2026
8cf4f7d to
f80a0d5
Compare
alliscode
approved these changes
Feb 4, 2026
f80a0d5 to
2976f5a
Compare
2976f5a to
b5f3ddf
Compare
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.
Motivation and Context
JSON Checkpoint serialization is currently strict in the ordering of the metadata properties, such as the polymorphic type specifier. This causes problems when deserializing checkpoints stored as JSONB in Postgres, which provides a different order on read.
Description
Create a way to let the user specify that a relaxed ordering is also allowed.
Contribution Checklist
Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.