Skip to content

Python: support ChatKit generated image conversion - #8844

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
quifox:feat/chatkit-generated-image
Oct 1, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
quifox:feat/chatkit-generated-image

Conversation

@quifox

@quifox quifox (quifox) commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

agent-framework-chatkit recognizes GeneratedImageItem, but the converter currently drops it with return []. This means generated images in ChatKit thread history are not provided back to the model on later turns.

Description & Review Guide

  • What are the major changes? Convert completed GeneratedImageItem instances into a user Message containing a short text preface and the generated image URI. Items without an image continue to be skipped. Expose an async generated_image_to_input() override hook and add coverage for data URI media types, external URLs, missing images, custom output, ordering, failures, and cancellation.
  • What is the impact of these changes? Generated images remain available as model context on later turns instead of being silently discarded. The default conversion mirrors openai-chatkit behavior. Content.from_uri() preserves embedded data URI media types; external URLs retain image/*. The async hook supports a Message, a list of messages, or None so applications can customize image context.
  • What do you want reviewers to focus on? Review MIME preservation and the async customization contract. Streaming output and attachment conversion remain outside this change.

Related Issue

Fixes #8842

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches the stated behavior and covers both conversion and missing-image handling.

Review effort: Balanced
Findings: None

What changed in this PR

Adds ChatKit generated images to subsequent model context.

Changes:

  • Converts completed generated images into multimodal user messages.
  • Continues skipping items without images.
  • Adds focused conversion and dispatch coverage.
File Description
python/​packages/​chatkit/​agent_framework_chatkit/​_converter.py Converts generated image URLs into image content.
python/​packages/​chatkit/​tests/​test_converter.py Verifies generated-image conversion behavior.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/chatkit/agent_framework_chatkit/_converter.py Outdated
@agent-framework-automation agent-framework-automation Bot added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Sep 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 30, 2026
Merged via the queue into microsoft:main with commit aa6c73c Oct 1, 2026
45 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 102626f2 Deployed Sep 30, 2026 by quifox via add_label #24096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Feature]: Support ChatKit generated image conversion

4 participants