Skip to content

[Chat] Normalize non-text AssistantMessage content in MessageNormalizer#2265

Open
Amoifr wants to merge 1 commit into
symfony:mainfrom
Amoifr:fix-2198-assistant-message-image-parts
Open

[Chat] Normalize non-text AssistantMessage content in MessageNormalizer#2265
Amoifr wants to merge 1 commit into
symfony:mainfrom
Amoifr:fix-2198-assistant-message-image-parts

Conversation

@Amoifr

@Amoifr Amoifr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #2198
License MIT

The original round-trip issue for UserMessage images (base64 vs. data URL mismatch) was already fixed by 8ca2ab0. This PR addresses the remaining case reported in the issue's follow-up: AssistantMessage content.

MessageNormalizer::normalizeAssistantParts() only handled Text, Thinking and ToolCall parts and silently dropped anything else. So an AssistantMessage carrying an Image (e.g. a generated image returned by Gemini) was lost on the way to the store and could not be read back.

File/Document/Image/Audio (as data URL) and ImageUrl/DocumentUrl parts are now handled on both the normalize and denormalize sides, mirroring what is already done for UserMessage content. Added a round-trip test for an AssistantMessage holding an Image.

normalizeAssistantParts() only handled Text, Thinking and ToolCall parts and
silently dropped any other content. An AssistantMessage carrying an Image (e.g.
a generated image returned by Gemini) was therefore lost when stored through the
MessageNormalizer and could not be read back.

Handle File/Document/Image/Audio (as data URL) and ImageUrl/DocumentUrl parts on
both sides, mirroring what is already done for UserMessage content.
@carsonbot carsonbot added Bug Something isn't working Chat Issues & PRs about the AI Chat component Status: Needs Review labels Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Chat Issues & PRs about the AI Chat component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent data serialization for images in MessageSerializer

2 participants