-
Notifications
You must be signed in to change notification settings - Fork 850
Expose ctors for setting AdditionalProperties on Hosted tools #7120
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
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 adds constructors to hosted tool classes that accept an IReadOnlyDictionary<string, object?> parameter, enabling users to set additional properties during instantiation. This addresses issues #7115 and #6570 by providing a cleaner API for configuring provider-specific tool properties like ranking options, filters, and image generation settings.
Key Changes:
- Added constructor overloads accepting
additionalPropertiesparameter to all hosted tool classes - Introduced
GetProperty<T>helper method for safe property extraction - Refactored OpenAI conversion logic to use the new helper and support additional properties
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| HostedCodeInterpreterTool.cs | Added constructor accepting additionalProperties and overrode AdditionalProperties property |
| HostedFileSearchTool.cs | Added constructor accepting additionalProperties and overrode AdditionalProperties property |
| HostedWebSearchTool.cs | Added constructor accepting additionalProperties and overrode AdditionalProperties property |
| HostedImageGenerationTool.cs | Added constructor accepting additionalProperties and overrode AdditionalProperties property |
| HostedMcpServerTool.cs | Added constructor overloads (for both string and Uri) accepting additionalProperties and overrode AdditionalProperties property |
| OpenAIClientExtensions.cs | Added GetProperty helper method for safe typed property extraction from AdditionalProperties |
| OpenAIResponsesChatClient.cs | Refactored conversion logic to use GetProperty helper for WebSearchTool, FileSearchTool, and ImageGenerationTool properties |
| OpenAIAssistantsChatClient.cs | Updated FileSearchTool conversion to extract RankingOptions from additional properties |
| HostedCodeInterpreterToolTests.cs | Added tests for new constructor with additionalProperties and null handling |
| HostedFileSearchToolTests.cs | Added tests for new constructor with additionalProperties and null handling |
| HostedWebSearchToolTests.cs | Added tests for new constructor with additionalProperties and null handling |
| HostedImageGenerationToolTests.cs | New test file with tests for constructor, options, and additionalProperties |
| HostedMcpServerToolTests.cs | Added tests for new constructors (string and Uri) with additionalProperties and null handling |
| OpenAIConversionTests.cs | Updated test to use new constructor; added comprehensive tests for FileSearchTool, ImageGenerationTool conversions with additional properties |
| Microsoft.Extensions.AI.Abstractions.json | Updated API baseline for stable hosted tools with new constructors and AdditionalProperties overrides |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
ericstj
left a comment
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.
Non-blocking questions / suggestions.
…#7120) * Expose ctors for setting AdditionalProperties on Hosted tools * Address feedback
|
We'll always be able to plumb members later, I was thinking if there might be a way to automatically keep them up to date. perhaps a source generator could do so. Might not be worth the effort if it doesn't change often. |
Closes #7115
Closes #6570
Microsoft Reviewers: Open in CodeFlow