feat(tool): Add media attachments to read tool#22258
feat(tool): Add media attachments to read tool#22258soaringk wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found no duplicate PRs that are currently addressing the same feature. The current PR (#22258) "Add media attachments to read tool" stands alone. While there are related PRs in the history (like #17204 about guarding text-only models from image attachments, and #21917 about omitting unsupported PDF tool-result attachments), these are separate concerns and not duplicates of the current PR. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
98f37ce to
f1a57b1
Compare
|
See: Sorry, I just found out the check is already there in the |
f1a57b1 to
60b7db1
Compare
Issue for this PR
Closes #22260
Type of change
What does this PR do?
The read tool already returned images and PDFs as file attachments, but it rejected audio and video files as generic binary files. This adds audio/video MIME detection before binary rejection, returns them as file attachments, and adds an attachment size guard before loading media into memory.
The attachment guard defaults to 256 MB and can be changed with OPENCODE_READ_MAX_ATTACHMENT_BYTES. Media routing now checks the model's explicit input capabilities for image, PDF, audio, and video. Audio/video are not kept inside tool results for providers that only support image/PDF tool-result media; they are routed through synthetic user file parts when supported, or converted to explicit error text when unsupported.
This also adds OpenAI-compatible chat-completions conversion for video file parts. Supported video file parts now serialize as video_url content parts, while unknown file media types still throw UnsupportedFunctionalityError.
How did you verify your code works?
Screenshots / recordings
Not a UI change.
Checklist