Repository navigation
Python: fix(openai): emit image_generation_call result from streaming output_item.done - #8424
Merged
Evan Mattson (moonbox3) merged 3 commits intoSep 17, 2026
Conversation
…item.done With the default `partial_images=0` the Responses API delivers the final image only once, as a completed `image_generation_call` item on `response.output_item.done`. The streaming parser had no branch for that item type, so the image was silently dropped and `AgentResponse` contained no image content, while the non-streaming parser mapped it correctly. Factor the non-streaming mapping into `_image_generation_item_to_contents` and use it from both parsers so streaming emits the same `image_generation_tool_call` + `image_generation_tool_result` contents. Fixes microsoft#8422 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 16, 2026 10:54 — with
GitHub Actions
Active
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 16, 2026 10:54 — with
GitHub Actions
Active
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 16, 2026 10:54 — with
GitHub Actions
Active
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 16, 2026 10:54 — with
GitHub Actions
Active
Eduard van Valkenburg (eavanvalkenburg)
deployed
to
github-app-auth
September 16, 2026 11:30 — with
GitHub Actions
Active
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 16, 2026 12:15 — with
GitHub Actions
Active
Evan Mattson (moonbox3)
approved these changes
Sep 17, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation & Context
When the hosted
image_generationtool runs withstream=Trueand the defaultpartial_images=0, the Responses API delivers the final image exactly once: as a completedimage_generation_callitem onresponse.output_item.done. The streaming parser in_chat_client.pyonly built image contents fromresponse.image_generation_call.partial_imageevents, and itsresponse.output_item.donehandler had no branch forimage_generation_call, so the image was silently dropped and never even reached the "unparsed event" debug log. The response ended up with only text and reasoning, history providers persisted no reference to the image, and becauseresponses.retrievereturnsresult: nullfor the item, the bytes were lost. The non-streaming parser handled the item correctly, so the two paths were not at parity. Affectsagent-framework-openaiandagent-framework-foundry.Description & Review Guide
image_generation_callmapping is factored into a private_image_generation_item_to_contents(item)helper (same mime detection viadetect_media_type_from_base64withimage/pngfallback, samedata:URI, sameimage_idandraw_representation), placed next to the existing_shell_item_to_contents. Both_parse_response_from_openaiand a newimage_generation_callbranch in the streamingresponse.output_item.donehandler call it, so streaming now emitsimage_generation_tool_callandimage_generation_tool_resultwith the final image.partial_imagehandler is unchanged. Withpartial_images > 0, callers get the preview frames flaggedis_partial_imagefollowed by the final result under the sameimage_id; no dedupe is done, the final render supersedes the previews. Items without aresult(for example a failed generation) emit the call plus a result withoutputs=None, matching the non-streaming path.elifin theoutput_item.donehandler and whether emitting on a result-less item is the desired semantics. Tests: three new tests next totest_parse_chunk_from_openai_with_file_search_call_donecover the final image, the result-less item, and streaming vs non-streaming parity viato_dict().Prepared with AI assistance (Claude Code) and human-verified: the new tests fail on
mainand pass with the fix;poe fmt,poe lint,poe pyright -P openai,poe mypy -P openaiand theopenaitest suite (511 passed, 95 skipped) were run locally.Related Issue
Fixes #8422
Contribution Checklist
🤖 Generated with Claude Code