Skip to content

Conversation

@jiwon-oai
Copy link
Collaborator

@jiwon-oai jiwon-oai commented Dec 17, 2025

Changes:

  • Add new types supported by ChatKit.js: GeneratedImageItem (thread item), GeneratedImage, GeneratedImageUpdated (thread item update)
  • stream_agent_response supports Agents SDK's ImageGenerationTool output
    • takes an optional ResponseStreamConverter to handle base64 image data string -> url conversion and partial image index -> progress conversion.

@jiwon-oai jiwon-oai force-pushed the generated-images-item branch 2 times, most recently from d169b14 to ba6e07a Compare December 17, 2025 22:23
@jiwon-oai jiwon-oai force-pushed the generated-images-item branch from ba6e07a to 51e0454 Compare December 18, 2025 04:59
Comment on lines 718 to 740
elif event.type == "response.image_generation_call.partial_image":
if not ctx.generated_image_item:
continue

url = await converter.base64_image_to_url(
event.item_id,
event.partial_image_b64,
event.partial_image_index,
)
progress = converter.partial_image_index_to_progress(
event.partial_image_index
)

ctx.generated_image_item.image = GeneratedImage(
id=event.item_id, url=url
)

yield ThreadItemUpdatedEvent(
item_id=ctx.generated_image_item.id,
update=GeneratedImageUpdated(
image=ctx.generated_image_item.image, progress=progress
),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

for readability should this block be above the done handlers?

Comment on lines 834 to 840
"""
Convert a GeneratedImageItem into input item(s) to send to the model.
Required when generated images are enabled.
"""
raise NotImplementedError(
"A GeneratedImageItem was included in a UserMessageItem but Converter.generated_image_to_message_content was not implemented"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm is there no way for us to represent images in a response? I'm not actually sure what the right thing to do here is, but can you just add image content by URL which we have?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I'll add a default that returns a ResponseInputImageParam

@jiwon-oai jiwon-oai force-pushed the generated-images-item branch from 876c31b to f3a2b1f Compare December 18, 2025 19:45
@jiwon-oai jiwon-oai added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 0b5b5b5 Dec 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants