Attach video files the same way as images - #967
Merged
Merged
Conversation
Accept standard video containers in prompts and send them as BinaryContent with video/* media types, skipping image normalization. http(s) links whose path ends in one of those containers become pydantic-ai VideoUrl parts. Co-authored-by: Mike Pfaffenberger <mike.pfaffenberger@gmail.com>
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
Prompt attachments now accept short local videos the same way they accept images (
@path, drag-and-drop, and path tokens). Remote http(s) links whose path ends in a supported container are sent as pydantic-aiVideoUrlparts. Clipboard paste stays image-only.Videos are
BinaryContentwith an explicitvideo/*media type. They never go throughnormalize_image_bytes/ PIL.Supported containers
.mp4,.m4vvideo/mp4.mov,.qtvideo/quicktime.webmvideo/webm.mkvvideo/x-matroska.avivideo/x-msvideo.mpeg,.mpgvideo/mpeg.wmvvideo/x-ms-wmv.flvvideo/x-flv.3gp,.3gppvideo/3gppMIME types are fixed in code so they do not depend on the host mime database.
.tsis not included because it collides with TypeScript sources.URL attachments
pydantic-ai 2.47 has
VideoUrl. Anhttp/httpsURL is attached only when the URL path ends in one of the extensions above (query strings are fine; quote the URL if it contains a#fragment, because the existing shell tokenizer treats#as a comment).Image and document URLs stay plain text, matching the previous behavior. YouTube and other page links are not auto-attached: they have no container suffix, and this change does not download remote video.
Provider caveats
Attachment plumbing stops at pydantic-ai parts. Models that cannot take video will still receive the bytes or URL and may error upstream.
In pydantic-ai 2.47:
BinaryContentto avideo_urldata URI andVideoUrlto avideo_urlpart. That is the path for OpenRouter models with native video input (for example MiniMax M3).NotImplementedErrorfor videoBinaryContentandVideoUrl.NotImplementedErrorfor video binary content andVideoUrl.There is no transcode step and no size cap on video attachments. The file bytes are sent as-is.
Tests
tests/test_command_line_attachments.py,tests/command_line/test_attachments.py, andtests/messaging/test_editor_display.pycover accepted extensions, MIME types, the image-normalization bypass,VideoUrllinks, and display tags. Existing image attachment tests still pass (134 tests in those files).