Skip to content

Support AVIF images or auto-convert to supported format before sending to API #17772

Closed

Description

@RaviTharuma

Description

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

  1. Have AVIF images in a directory (e.g., downloaded from Webflow)
  2. Use an agent with multimodal capabilities to analyze the images
  3. 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

Environment

  • OpenCode v1.2.26
  • macOS (Darwin 25.3.0)
  • Anthropic API via Quotio proxy

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 16, 2026
  2. github-actions commented on Mar 16, 2026

    @github-actions
    Contributor

    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.

  3. RaviTharuma commented on Mar 16, 2026

    @RaviTharuma
    Author

    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.

  4. zeke commented on Apr 5, 2026

    @zeke
    Contributor

    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.

  5. added a commit that references this issue on Apr 5, 2026
    b28b36a
  6. momoshell commented on Apr 29, 2026

    @momoshell

    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.

  7. Robin1987China commented on Aug 11, 2026

    @Robin1987China
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions