feat: support multimodal input in agent chat#2717
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2717 +/- ##
==========================================
- Coverage 93.70% 93.66% -0.05%
==========================================
Files 504 504
Lines 51120 51248 +128
==========================================
+ Hits 47904 48003 +99
- Misses 3216 3245 +29
🚀 New features to boost your workflow:
|
Sort __all__ exports and import Sequence from collections.abc. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for multimodal messages in the agents chat module by adding the ImageContent class and updating Message and AgentMessage to handle sequences of content parts. Feedback recommends checking the raw byte size of image data before base64 encoding to prevent memory overhead, and validating sequence elements in Message.__init__ to ensure type safety and prevent runtime crashes.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Convert strings in content sequences to TextContent and raise TypeError for invalid item types to prevent runtime failures during serialization. Co-authored-by: Cursor <cursoragent@cursor.com>
Add a list-item type ignore when passing invalid content parts to Message. Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid duplicating the API payload limit in the SDK so validation cannot drift from the service contract. Co-authored-by: Cursor <cursoragent@cursor.com>
| ... | ||
|
|
||
| @classmethod | ||
| def _load_content_value( |
There was a problem hiding this comment.
shouldn't ToolConfirmationCall._load_call support the array now as well?
There was a problem hiding this comment.
If I understand the question correctly, then no, because the tool confirmation call is made by the agent to the user - we now support multimodal input, but not multimodal output
|
update from master so CI succeeds |
Summary
ImageContentmessage content type withfrom_file()andfrom_bytes()helpers for loading images from diskMessageto accept multimodal content as a list of text and image partsAssociated service contract change: https://github.com/cognitedata/service-contracts/pull/3303
Manual Test
To see the new feature in action, try out the following script:
Test plan
ImageContent.from_file/from_bytesMessageserializationMade with Cursor