Use image-generation output_format for the result media type - #1132
PratikDhanave (PratikDhanave) wants to merge 2 commits into
Conversation
The non-streaming and output_item.done image-generation paths hardcoded a png media type on the emitted result, so a webp/jpeg image was mislabeled image/png. The streaming partial path already derives it from the call's output_format. Use cmp.Or(item.OutputFormat, "png") at both remaining sites, matching the partial path and the Python client.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The streaming fallback path lacks regression coverage for non-PNG output formats.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates image-generation result media types to honor output_format instead of defaulting to PNG.
Changes:
- Uses
OutputFormatfor non-streaming and streaming fallback results. - Adds WebP regression coverage for non-streaming responses.
| File | Summary |
|---|---|
provider/openaiprovider/responses.go |
Derives image media types from output format. |
provider/openaiprovider/responses_test.go |
Tests WebP media type handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // for this item, so emit only the finished result here to avoid a | ||
| // duplicate tool call. | ||
| u.Contents = []message.Content{imageGenerationResult(item.ID, item.Result, "png", item)} | ||
| u.Contents = []message.Content{imageGenerationResult(item.ID, item.Result, cmp.Or(item.OutputFormat, "png"), item)} |
This comment has been minimized.
This comment has been minimized.
Add a no-partial streaming test so the output_item.done image-generation fallback path (not just the non-streaming path) is verified to honor output_format for the result media type.
|
Scope: user-visible behavior (internal implementation, but observable via
|

The Responses image-generation result media type was hardcoded to
pngon two paths —imageGenerationContents(non-streaming) and theoutput_item.donenon-partial fallback — so an image generated as webp/jpeg was surfaced asimage/png. The streaming partial path already does this correctly withcmp.Or(event.OutputFormat, "png").Python derives the media type from the image (
detect_media_type_from_base64(...) or "image/png"); the call also carriesoutput_format.Change
"png"literals withcmp.Or(item.OutputFormat, "png")(ResponseOutputItemImageGenerationCall.OutputFormat), matching the partial path.Test
TestResponsesImageGenerationCall_UsesOutputFormat: animage_generation_callwith"output_format":"webp"now yieldsimage/webp. Fails before (image/png), passes after.