You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support AVIF images or auto-convert to supported format before sending to API #17772
When OpenCode reads AVIF images (e.g., from downloaded Webflow assets) and sends them to the Anthropic API for vision/multimodal analysis, the API rejects them because AVIF is not a supported media type.
Steps to Reproduce
Have AVIF images in a directory (e.g., downloaded from Webflow)
Use an agent with multimodal capabilities to analyze the images
The agent reads the .avif file and sends it to the API
Expected Behavior
OpenCode should either:
Auto-convert AVIF to a supported format (PNG/JPEG/WebP) before sending to the API
Or skip unsupported formats gracefully with a clear warning
Actual Behavior
The API returns a validation error in an infinite loop:
messages.502.content.0.tool_result.content.1.image.source.base64.media_type: Input should be 'image/jpeg', 'image/png', 'image/gif' or 'image/webp'
Additionally, if the file doesn't exist:
ENOENT: no such file or directory, open '/tmp/wf-imgs/659d681d7b333c788f3209b2_patrick-riedel_square.avif'
The agent enters a retry loop hitting the same error repeatedly.
Additional Context
AVIF is increasingly common on modern websites (Webflow, Squarespace, etc.)
macOS has native AVIF→PNG conversion via sips -s format png input.avif --out output.png
The Anthropic API supports: image/jpeg, image/png, image/gif, image/webp
This issue might be a duplicate of existing issues. Please check:
Feature: Media type validation/conversion for MCP tool results #12519: Same root cause — unsupported image media types (e.g., SVG, BMP, TIFF) being sent to the Anthropic API, with the same error message and the same proposed solutions (auto-convert or skip unsupported formats)
Thanks for flagging the related issues. This is indeed the same root cause as #12519 and #10609 — unsupported image formats hitting the API without conversion.
I've submitted PR #17774 which addresses all three issues by adding auto-conversion of unsupported image formats (AVIF, HEIC, HEIF, JXL, TIFF, BMP) to PNG in File.read(), with a sharp → sips → ffmpeg fallback chain.
Same issue with BMP files. Reading a .bmp file sends image/bmp to the Anthropic API, which rejects it, and the error gets baked into the conversation history making the session unrecoverable.
The root cause is in read.ts — the image check is mime.startsWith("image/") with only SVG and fastbidsheet excluded. This lets through BMP, TIFF, HEIC, AVIF, JXL, and any other image/* type that providers do not support.
A minimal fix would be to allowlist the formats that providers actually accept (image/jpeg, image/png, image/gif, image/webp) and return an error message for unsupported formats instead of trying to encode and send them. Working on a PR for this.
Hit this on opencode 1.14.21 with a .dxf file (CAD) — same error path: messages.110.content.2.tool_result.content.1.image.source.base64.media_type: Input should be 'image/jpeg', 'image/png', 'image/gif' or 'image/webp'
The agent had just written a tiny .dxf fixture and read it back; the read tool attached it as media_type=image/vnd.dxf and the session stayed bricked because the bad block lives in history and gets replayed every retry.
Same root cause as #23990 / #15264. Just saw #21114 from @zeke — looks like it covers this case too (image/vnd.dxf falls outside the allowlist). Withdrawing my assignment ask.
For anyone tracking AVIF support: AVIF images are still not sent to the model — in V2 the TUI accepts .avif attachments and inserts an [Image N] label, but the image is silently dropped when building the model request. I filed #41722 and opened PR #41723 which preserves unsupported image formats as a descriptive text attachment (instead of silently dropping them) so the model is aware of the attachment and can respond accordingly. Thumbs up on the PR if this matters to your workflow.
Activity
github-actions commentedon Mar 16, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and consider adding your details there if they cover the same problem.
RaviTharuma commentedon Mar 16, 2026
Thanks for flagging the related issues. This is indeed the same root cause as #12519 and #10609 — unsupported image formats hitting the API without conversion.
I've submitted PR #17774 which addresses all three issues by adding auto-conversion of unsupported image formats (AVIF, HEIC, HEIF, JXL, TIFF, BMP) to PNG in
File.read(), with a sharp → sips → ffmpeg fallback chain.zeke commentedon Apr 5, 2026
Same issue with BMP files. Reading a
.bmpfile sendsimage/bmpto the Anthropic API, which rejects it, and the error gets baked into the conversation history making the session unrecoverable.The root cause is in
read.ts— the image check ismime.startsWith("image/")with only SVG and fastbidsheet excluded. This lets through BMP, TIFF, HEIC, AVIF, JXL, and any otherimage/*type that providers do not support.A minimal fix would be to allowlist the formats that providers actually accept (
image/jpeg,image/png,image/gif,image/webp) and return an error message for unsupported formats instead of trying to encode and send them. Working on a PR for this.fix(read): reject unsupported image formats before sending to provider
momoshell commentedon Apr 29, 2026
Hit this on opencode 1.14.21 with a .dxf file (CAD) — same error path:
messages.110.content.2.tool_result.content.1.image.source.base64.media_type: Input should be 'image/jpeg', 'image/png', 'image/gif' or 'image/webp'The agent had just written a tiny .dxf fixture and read it back; the read tool attached it as
media_type=image/vnd.dxfand the session stayed bricked because the bad block lives in history and gets replayed every retry.Same root cause as #23990 / #15264. Just saw #21114 from @zeke — looks like it covers this case too (
image/vnd.dxffalls outside the allowlist). Withdrawing my assignment ask.Robin1987China commentedon Aug 11, 2026
For anyone tracking AVIF support: AVIF images are still not sent to the model — in V2 the TUI accepts
.avifattachments and inserts an[Image N]label, but the image is silently dropped when building the model request. I filed #41722 and opened PR #41723 which preserves unsupported image formats as a descriptive text attachment (instead of silently dropping them) so the model is aware of the attachment and can respond accordingly. Thumbs up on the PR if this matters to your workflow.