Skip to content

Fix multimodal serialization#351

Merged
jamesbraza merged 4 commits intomainfrom
fix-image-serialization
Apr 16, 2026
Merged

Fix multimodal serialization#351
jamesbraza merged 4 commits intomainfrom
fix-image-serialization

Conversation

@sidnarayanan
Copy link
Copy Markdown
Collaborator

  1. We were losing content_is_json_str
  2. Downstream code would sometimes incorrectly check Message.content, which can sometimes be a serialized list. As a helper, we provide Message.serialized_content. Should we cache this? Up for discussion.

@sidnarayanan sidnarayanan requested review from a team and Copilot April 15, 2026 01:31
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 15, 2026
@dosubot dosubot bot added the bug Something isn't working label Apr 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes multimodal Message serialization so content_is_json_str is not lost in certain dump/roundtrip flows, and provides a safer helper for downstream code to use API-ready content.

Changes:

  • Ensure content_is_json_str is emitted during model_dump(..., context={"include_info": True}) when applicable.
  • Centralize content shaping during serialization via a new Message.serialized_content helper.
  • Add/extend tests covering multimodal dump expectations and dump→validate roundtrips.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/aviary/message.py Adjusts serialization logic and preserves content_is_json_str when include_info is set; adds serialized_content helper.
tests/test_messages.py Adds expectations and roundtrip tests for multimodal serialization and content_is_json_str preservation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/aviary/message.py
Comment thread tests/test_messages.py Outdated
Copy link
Copy Markdown
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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

Nice work! Tests are great

Comment thread src/aviary/message.py
Comment thread src/aviary/message.py Outdated
@jamesbraza jamesbraza merged commit 522cbcb into main Apr 16, 2026
5 checks passed
@jamesbraza jamesbraza deleted the fix-image-serialization branch April 16, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants