Skip to content

Add AVIF support for local file attachments - #1735

Open
by-ae wants to merge 2 commits into
RailtownAI:mainfrom
by-ae:cursor/fix-avif-support-0f27
Open

by-ae wants to merge 2 commits into
RailtownAI:mainfrom
by-ae:cursor/fix-avif-support-0f27

Conversation

@by-ae

@by-ae by-ae commented Oct 22, 2026

Copy link
Copy Markdown

Summary

Local .avif files are now handled consistently with base64 AVIF input. Previously, Attachment("photo.avif") raised "Unsupported attachment format" because .avif was missing from _EXTENSION_MIME_MAP, even though base64 AVIF was accepted after #1623. This PR adds .avif -> image/avif to the extension map, unifying the two input paths, and updates the docs to match.

Fixes #1730

Type of change

  • Bug fix
  • Feature
  • Breaking change
  • Docs
  • Refactor / chore / build / tests

Checklist

  • Lint & format pass (ruff check . && ruff format .)
  • Tests added/updated and pass locally (pytest tests)
  • Docs updated if user-facing behavior changed (added AVIF to the supported image formats in docs/documentation/agent_design/llms/modalities.md, with a note on varying provider support)
  • Breaking changes include migration notes (N/A: no breaking changes; previously rejected .avif paths are now accepted)

Notes

What was wrong: The local file path .avif -> MIME lookup rejected .avif extensions, while the base64 path accepted image/avif via magic-byte detection in attachment_formats.yaml. A URL ending in .avif was not rejected either, since it fell through to the provider as-is.

What changed:

  • Added .avif: image/avif to _EXTENSION_MIME_MAP in message.py, placed alphabetically first per repository convention.
  • Added AVIF to the supported image formats list in modalities.md.

How it was tested:

  • Added test_local_avif_consistent_with_base64, which verifies local .avif files and base64 AVIF payloads are handled consistently
  • Extended the existing test_local_file_formats parametrized test to include .avif
  • All 79 message tests and 992 core unit tests pass
  • Lint and format checks pass

Note on provider support: OpenAI, Anthropic, and Gemini do not officially list AVIF among their accepted image formats, so this swaps today's early, clear error for a possible provider rejection at request time. Some OpenAI-compatible servers (such as PIL-based ones) do support AVIF, and this matches the existing behavior for URLs ending in .avif, which already pass through without early rejection.

by-ae and others added 2 commits October 22, 2026 21:49
Local .avif files are now handled consistently with base64 AVIF input.
Previously, Attachment('photo.avif') raised 'Unsupported attachment format'
because .avif was missing from _EXTENSION_MIME_MAP, even though base64 AVIF
was accepted after RailtownAI#1623.

This adds .avif -> image/avif to the extension map, unifying the two input
paths. A URL ending in .avif also works (no-op, already passed through).

Fixes RailtownAI#1730

Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Update modalities.md to include AVIF among supported image formats and
add a note about varying provider support for AVIF, since OpenAI,
Anthropic, and Gemini do not officially list it while some
OpenAI-compatible servers do support it.

Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@by-ae

by-ae commented Oct 22, 2026

Copy link
Copy Markdown
Author

Heads up: this overlaps with #1734, which was opened a few minutes earlier for the same issue. Happy to close this one if you prefer that PR. The main difference is that this one also adds AVIF to the supported image formats in docs/documentation/agent_design/llms/modalities.md, so if you go with #1734 that docs line may be worth carrying over.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local .avif files are rejected while base64 AVIF is accepted

1 participant