Stabilize ImageGeneration content types and HostedImageGenerationTool#7476
Stabilize ImageGeneration content types and HostedImageGenerationTool#7476
Conversation
Remove [Experimental] from ImageGenerationToolCallContent, ImageGenerationToolResultContent, and HostedImageGenerationTool so IChatClient consumers can use them without MEAI001 suppression. - Uncomment [JsonDerivedType] on AIContent, ToolCallContent, and ToolResultContent for the two content types - Remove corresponding AddAIContentTypeChain runtime workarounds and [JsonSerializable] entries from AIJsonUtilities.Defaults - Update API baseline (Experimental -> Stable) - Add targeted #pragma for ImageGenerationOptions in HostedImageGenerationToolTests (still experimental) - Add Stabilization.Tests project that builds without MEAI001 to verify no experimental leakage Co-authored-by: Copilot <[email protected]>
f26218c to
fe24b54
Compare
There was a problem hiding this comment.
Pull request overview
This PR is part of the Microsoft.Extensions.AI content-type stabilization effort, aiming to let IChatClient consumers process image-generation tool call/result content without suppressing MEAI001, by stabilizing the relevant content/tool types and wiring them into polymorphic JSON serialization.
Changes:
- Removed
[Experimental]fromImageGenerationToolCallContent,ImageGenerationToolResultContent, andHostedImageGenerationTool, and updated the public API stage metadata accordingly. - Registered the image-generation tool call/result content types via
[JsonDerivedType]onAIContent/ToolCallContent/ToolResultContent, and removed the priorAIJsonUtilitiesworkaround entries. - Added a new stabilization test project that links existing tests without project-level
MEAI001suppression.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.AI.Stabilization.Tests/Microsoft.Extensions.AI.Stabilization.Tests.csproj | New stabilization test project to ensure stabilized types don’t require MEAI001 suppression. |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedImageGenerationToolTests.cs | Local MEAI001 suppression around ImageGenerationOptions usage (which remains experimental). |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Defaults.cs | Removes image-generation-specific JSON workaround registration now that types are stabilized and registered via attributes. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedImageGenerationTool.cs | Removes [Experimental] from the hosted tool marker type. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json | Updates API stage metadata (and assembly version) to reflect stabilization. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/ToolResultContent.cs | Adds [JsonDerivedType] mapping for ImageGenerationToolResultContent. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/ToolCallContent.cs | Adds [JsonDerivedType] mapping for ImageGenerationToolCallContent. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/ImageGenerationToolResultContent.cs | Removes [Experimental] from image-generation tool result content type. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/ImageGenerationToolCallContent.cs | Removes [Experimental] from image-generation tool call content type. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/AIContent.cs | Adds [JsonDerivedType] mappings for the image-generation tool call/result content types. |
ericstj
left a comment
There was a problem hiding this comment.
So long as this can be used without opting into experimental ImageGenerationOptions it seems OK. I bet we can come close to stabilizing ImageGenerationOptions though.
Remove [Experimental] from ImageGenerationOptions and ImageGenerationResponseFormat, update API baselines, and remove the #pragma workaround in HostedImageGenerationToolTests. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Fix misleading XML docs on ImageGenerationToolResultContent that described it as a tool call rather than a tool result. Add ProjectUnderTest attribute to Stabilization.Tests project references. Co-authored-by: Copilot <[email protected]>
…Hosted The member was experimental but still present in the 10.4.0 baseline binary. Suppress CP0002 for all target frameworks. Co-authored-by: Copilot <[email protected]>
…ntegration test - Restore ImageGenerationResponseFormat.Hosted with [Experimental] attribute - Add UseImageGeneration_ProducesImageContent integration test for Responses API image generation tool Co-authored-by: Copilot <[email protected]>
The CP0002 suppressions are no longer needed since Hosted was restored. Co-authored-by: Copilot <[email protected]>
|
I'm not adding ImageGenerationOptionsTests to MEAI.Stabilization.Tests because they do sourcegen serialization which will trip up with the Experimental types it references. |
…#7476) * Stabilize ImageGeneration content types and HostedImageGenerationTool Remove [Experimental] from ImageGenerationToolCallContent, ImageGenerationToolResultContent, and HostedImageGenerationTool so IChatClient consumers can use them without MEAI001 suppression. - Uncomment [JsonDerivedType] on AIContent, ToolCallContent, and ToolResultContent for the two content types - Remove corresponding AddAIContentTypeChain runtime workarounds and [JsonSerializable] entries from AIJsonUtilities.Defaults - Update API baseline (Experimental -> Stable) - Add targeted #pragma for ImageGenerationOptions in HostedImageGenerationToolTests (still experimental) - Add Stabilization.Tests project that builds without MEAI001 to verify no experimental leakage Co-authored-by: Copilot <[email protected]> * Stabilize ImageGenerationOptions and ImageGenerationResponseFormat Remove [Experimental] from ImageGenerationOptions and ImageGenerationResponseFormat, update API baselines, and remove the #pragma workaround in HostedImageGenerationToolTests. Co-authored-by: Copilot <[email protected]> * Remove unused ImageGenerationResponseFormat.Hosted enum member Co-authored-by: Copilot <[email protected]> * Address PR feedback: fix XML docs and add ProjectUnderTest Fix misleading XML docs on ImageGenerationToolResultContent that described it as a tool call rather than a tool result. Add ProjectUnderTest attribute to Stabilization.Tests project references. Co-authored-by: Copilot <[email protected]> * Add API compat suppression for removed ImageGenerationResponseFormat.Hosted The member was experimental but still present in the 10.4.0 baseline binary. Suppress CP0002 for all target frameworks. Co-authored-by: Copilot <[email protected]> * Add Hosted enum value back as experimental and add image generation integration test - Restore ImageGenerationResponseFormat.Hosted with [Experimental] attribute - Add UseImageGeneration_ProducesImageContent integration test for Responses API image generation tool Co-authored-by: Copilot <[email protected]> * Remove CompatibilitySuppressions.xml for Hosted enum value The CP0002 suppressions are no longer needed since Hosted was restored. Co-authored-by: Copilot <[email protected]> * Add ImageGenerationResponseFormat.Hosted test and api baseline back --------- Co-authored-by: Copilot <[email protected]>
As part of the broader effort to stabilize content types, this PR removes
[Experimental]fromImageGenerationToolCallContent,ImageGenerationToolResultContent, andHostedImageGenerationTool, the three types directly surfaced toIChatClientconsumers so they can process image generation responses without suppressingMEAI001.ImageGenerationOptionsremains experimental. I feel that it will be inconsistent to stabilize it without also doing it for the rest of the image generation types. So I'm starting the discussion with the cheapest approach.The alternatives are:
One reason to go all-in on image generation is that the surface area is exercised almost in its entirety (only
ImageGenerationResponseFormat.Hostedis not used) by these libraries:OpenAIImageGenerator+OpenAIResponsesChatClientGoogleGenAIImageGeneratorPredictionServiceImageGeneratorBedrockImageGeneratorMicrosoft Reviewers: Open in CodeFlow