-
Notifications
You must be signed in to change notification settings - Fork 849
Preserve extra JSON schema properties in ToolJson serialization #7250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…defs Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
There was a problem hiding this 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 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 |
…rties Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
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