feat(tool): Add media attachments to read tool#22258
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
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
@rekram1-node this is an important capability. Please reopen and merge this one. Without something like this, we have no path in opencode to attach and hand video files to models that support them. |
|
ill check what's needed for that, this PR is a bit out of date at this point Idk if any of the mainstream agents support video and audio files w/ their read tools, havent experimented with that |
You're the best. It would be a great add for OpenCode, and an increasing number of the significant LLMs are now multimodal. It would be super helpful to be able to get audio and video data into those models with OpenCode. I would use it all the time! |
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