Skip to content

Stabilize ImageGeneration content types and HostedImageGenerationTool#7476

Merged
jozkee merged 8 commits intomainfrom
dacantu/imagegen-stabilization
Apr 24, 2026
Merged

Stabilize ImageGeneration content types and HostedImageGenerationTool#7476
jozkee merged 8 commits intomainfrom
dacantu/imagegen-stabilization

Conversation

@jozkee
Copy link
Copy Markdown
Member

@jozkee jozkee commented Apr 20, 2026

As part of the broader effort to stabilize content types, this PR removes [Experimental] from ImageGenerationToolCallContent,
ImageGenerationToolResultContent, and HostedImageGenerationTool, the three types directly surfaced to IChatClient consumers so they can process image generation responses without suppressing MEAI001.

ImageGenerationOptions remains 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:

  • Remove experimental also from ImageGenerationOptions.
  • Entirely remove experimental from all Image generation APIs.

One reason to go all-in on image generation is that the surface area is exercised almost in its entirety (only ImageGenerationResponseFormat.Hosted is not used) by these libraries:

Microsoft Reviewers: Open in CodeFlow

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]>
Copilot AI review requested due to automatic review settings April 20, 2026 20:39
@jozkee jozkee requested a review from a team as a code owner April 20, 2026 20:39
@github-actions github-actions Bot added the area-ai Microsoft.Extensions.AI libraries label Apr 20, 2026
@jozkee jozkee force-pushed the dacantu/imagegen-stabilization branch from f26218c to fe24b54 Compare April 20, 2026 20:39
@jozkee jozkee requested a review from ericstj April 20, 2026 20:40
Copy link
Copy Markdown
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 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] from ImageGenerationToolCallContent, ImageGenerationToolResultContent, and HostedImageGenerationTool, and updated the public API stage metadata accordingly.
  • Registered the image-generation tool call/result content types via [JsonDerivedType] on AIContent / ToolCallContent / ToolResultContent, and removed the prior AIJsonUtilities workaround entries.
  • Added a new stabilization test project that links existing tests without project-level MEAI001 suppression.

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.

Copy link
Copy Markdown
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.

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.

jozkee and others added 4 commits April 21, 2026 10:51
Remove [Experimental] from ImageGenerationOptions and
ImageGenerationResponseFormat, update API baselines, and remove
the #pragma workaround in HostedImageGenerationToolTests.

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]>
jozkee and others added 2 commits April 22, 2026 21:08
@jozkee
Copy link
Copy Markdown
Member Author

jozkee commented Apr 23, 2026

I'm not adding ImageGenerationOptionsTests to MEAI.Stabilization.Tests because they do sourcegen serialization which will trip up with the Experimental types it references.

@jozkee jozkee merged commit 689ae13 into main Apr 24, 2026
6 checks passed
@jozkee jozkee deleted the dacantu/imagegen-stabilization branch April 24, 2026 03:12
jeffhandley pushed a commit that referenced this pull request May 1, 2026
…#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]>
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

Development

Successfully merging this pull request may close these issues.

4 participants