feat: Add task-native and agent-native multimodality support #4004
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
This PR implements native multimodality support for crewAI Agents and Tasks, addressing feature request #3860.
Changes
New Modules
multimodal/image.py
Imageclass for handling images in multiple formats:from_url()from_file()with automatic MIME type detectionfrom_base64()from_binary()from_placeholder()to_data_url(),to_message_content()multimodal/multipart_content.py
MultipartContentclass for managing compound text+image contextadd_text(),add_image(),to_message_content()get_text_only(),has_images()Integration
agent/core.py and task.py
multipart_contextfield to both Agent and Task classeslist[str | Image] | MultipartContent | NoneUsage Example
Testing
Comprehensive test suite included in
tests/multimodal/:test_image.py: 19 test cases covering all Image class functionalitytest_multipart_content.py: 13 test cases for MultipartContentrun_tests.py: Custom test runner for environments without pytestvalidate_implementation.py: Syntax and structure validationAll validation checks pass successfully.
Closes
#3860
Note
Introduces multimodal support via new Image and MultipartContent classes and integrates them as multipart_context on Agent and Task, with comprehensive tests.
crewai/multimodal/):Image: constructors for URL/file/base64/binary/placeholder; conversion to data URLs and LLM message content.MultipartContent: manage mixed text+images; convert to LLM message parts; text-only extraction and helpers.crewai/agent/core.py: addmultipart_context: list[str | Image] | MultipartContent | Noneto include multimodal context in system prompt.crewai/task.py: addmultipart_context: list[str | Image] | MultipartContent | Noneto enrich task context.tests/multimodal/):ImageandMultipartContent; integration checks; standalone runner and validator.Written by Cursor Bugbot for commit 448c815. This will update automatically on new commits. Configure here.