autogen-ext: Support Image generation message on ai agent #7156
+24
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
This PR adds support for handling image generation results returned via the OpenAI Responses API in the
OpenAIagent message stream.Previously, the agent primarily relied on
response_obj.output_text(or a fallback placeholder) and would therefore miss non-text outputs contained inresponse_obj.output, such as image generation tool calls. As a result, image-generation-capable models/tools could successfully generate images, but the agent would not surface them to downstream consumers (and message history would not reflect them).With this change, the agent:
response_obj.outputwhen present.ImageGenerationCallresults (base64) intoAddImageitems so downstream UIs/clients can render images.ResponseOutputMessageparts and returnsTextMessagewhen output is purely textual.MultiModalMessagewhen the output includes non-string content (e.g., images), while preserving message history semantics.This enables image generation responses to be delivered through the same streaming interface and message abstractions used by other modalities.
Related issue number
N/A
Checks