Preserve extra JSON schema properties in ToolJson serialization#7250
Merged
stephentoub merged 3 commits intomainfrom Feb 2, 2026
Merged
Preserve extra JSON schema properties in ToolJson serialization#7250stephentoub merged 3 commits intomainfrom
stephentoub merged 3 commits intomainfrom
Conversation
…defs Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ToolsJson structure to include definitions object
Preserve extra JSON schema properties in ToolJson serialization
Jan 31, 2026
stephentoub
approved these changes
Jan 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where ToolJson was stripping extra top-level JSON schema properties (such as $defs and definitions) during serialization roundtrip, causing function calls with reference types to fail.
Changes:
- Added
[JsonExtensionData]attribute toToolJsonclass to preserve unrecognized schema properties - Added comprehensive test verifying
$defsproperty preservation through the conversion pipeline
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs | Added ExtensionData property with [JsonExtensionData] attribute to ToolJson class to preserve extra schema properties like $defs and definitions |
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs | Added test AsOpenAIChatTool_PreservesExtraTopLevelPropertiesLikeDefs that validates $defs property is preserved during function declaration to OpenAI tool conversion |
eiriktsarpalis
approved these changes
Feb 2, 2026
…rties Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This was referenced Feb 11, 2026
This was referenced Feb 16, 2026
Merged
Bump Microsoft.Extensions.Http.Resilience from 10.0.0 to 10.3.0
dotnet-presentations/ai-workshop#339
Closed
Bump Microsoft.Extensions.Http.Resilience from 10.2.0 to 10.3.0
dotnet-presentations/ai-workshop#342
Open
Open
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.
ToolJsonclass strips extra JSON properties (like$defs/definitions) when converting AI function declarations to OpenAI tool parametersJsonExtensionDatato preserve unknown properties inToolJsonOpenAIClientExtensions.cs$defsand other properties are preservedOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Microsoft Reviewers: Open in CodeFlow