feat(text): support native multimodal message parts#283
Merged
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Summary
Make text chat messages natively multimodal instead of forcing media through top-level analyze helpers or provider-specific request patches.
This PR introduces a narrow, ordered message-content model:
MessageContent = str | list[MessagePart]MessagePart = TextPart | ImagePart | AudioPart | VideoPart | DocumentPartwith atypediscriminatorArtifactobjects inside their corresponding part wrappersToolResultis now a separate message-list item withToolResultContent, not aMessagesubclassThe intended app shape is now:
Why
Celeste text clients already expose chat-style
generate(messages=...), but message content could not reliably represent native media parts. Mixed raw content like['text', ImageArtifact(...)]could validate through loose fallbacks, serialize as anonymous JSON, and round-trip without preserving semantic type.This PR makes Celeste-AI the semantic owner of multimodal chat input:
Message+MessagePartvaluesPublic API changes
MessageContent,MessagePart,TextPart,ImagePart,AudioPart,VideoPart,DocumentPart, andToolResultContent.Contentalias from public message typing.Message.contentto plain text or an ordered list of message parts.ImageArtifact,AudioArtifact,VideoArtifact, andDocumentArtifactvalues.ToolResult.contentstructured throughToolResultContent; structured tool payloads no longer travel as normalMessage.content.Breaking changes
Message.content.["text", ImageArtifact(...)]are no longer validMessage.content.Message.content; useToolResult.contentfor structured tool results.Contentalias must migrate toMessageContent,TextContent, media content aliases, orToolResultContentdepending on intent.ToolResultas aMessagesubclass must treat it as its own message-list item.Code changes
src/celeste/messages.pyas the canonical helper layer for:messagesacceptslist[Message | ToolResult].Skill/reference updates
Adds the
celeste-pythonagent skill to the repository with current SDK guidance for future agents. The skill documents:MessagePartusagesrc/celeste/messages.pyhelper seamMessage.content.agents/is normally ignored, so these files were intentionally force-added for this PR.Tests
Adds or updates unit coverage for:
ToolResultfromMessageValidation
uv run python -m compileall -q src/celesteuv run ruff checkon touched SDK and test filesuv run pytest tests/unit_tests/test_text_multimodal_message_content.py tests/unit_tests/test_text_multimodal_message_request_building.py tests/unit_tests/test_text_tool_results.py tests/unit_tests/test_tool_outputs.py tests/unit_tests/test_text_media_support_validation.py tests/unit_tests/test_telemetry_content_events.py tests/unit_tests/test_io.py -q(58 passed)uv run mypy src/celesteNot included
Contentalias shim.