Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Dec 9, 2025

Closes #7115
Closes #6570

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner December 9, 2025 23:37
Copilot AI review requested due to automatic review settings December 9, 2025 23:37
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Dec 9, 2025
Copy link
Contributor

Copilot AI left a 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 additionalProperties parameter 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

Copy link
Member

@ericstj ericstj left a 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.

@stephentoub stephentoub enabled auto-merge (squash) December 12, 2025 03:47
@stephentoub stephentoub merged commit e30c4c0 into dotnet:main Dec 12, 2025
6 checks passed
@stephentoub stephentoub deleted the hostedprops branch December 12, 2025 04:44
stephentoub added a commit to ericstj/extensions that referenced this pull request Dec 12, 2025
…#7120)

* Expose ctors for setting AdditionalProperties on Hosted tools

* Address feedback
@ericstj
Copy link
Member

ericstj commented Dec 12, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

2 participants