Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Gemini models reject GIF images (supported formats: PNG, JPEG, WEBP, HEIC, HEIF). Users hitting this when attaching GIFs or switching models mid-conversation.

Changes

Model capabilities (chatModelCapabilities.ts):

  • Added GEMINI_SUPPORTED_IMAGE_MIME_TYPES constant
  • Added isGeminiFamily() and modelSupportsImageMimeType() helpers

Image attachments (image.tsx):

  • Check format support before rendering, show clear error for unsupported types
  • Added getFormatFromMimeType() helper with fallback for malformed MIME types

Message conversion (geminiMessageConverter.ts):

  • Filter unsupported images from user messages and tool results using constant

Example:

// New attachments with Gemini
if (imageMimeType && !modelSupportsImageMimeType(endpoint, imageMimeType)) {
  // Shows: "Gemini does not support GIF images. Supported formats: PNG, JPEG, WEBP, HEIC, HEIF."
  return <OmittedReference />;
}

// Conversation history filtering
const isSupported = !mimeType.startsWith('image/') || 
  GEMINI_SUPPORTED_IMAGE_MIME_TYPES.includes(mimeType);

Added 16 unit tests covering model detection and image filtering.

Original prompt

This section details on the original issue you should resolve

<issue_title>Gemini handling for image/gif needs improvement</issue_title>
<issue_description>Gemini models do not support GIF images, see https://ai.google.dev/gemini-api/docs/image-understanding#supported-formats
We need to make sure that either we don't allow attaching it when Gemini is selected or to convert the image instance on upload to png. When transferring from another model, we also need to drop those image/gif references retroactively.</issue_description>

Comments on the Issue (you are @copilot in this section)

@isidorn @pwang347 any way to try to handle this as part of January? CAPI just raised this as happening often - I can get the data to see how often it really happens, just let me know @vijayupadya @isidorn is the issue CAPI raised about the general image type required issue (err below) OR specifically GIF issue?

Request Failed: 400 {"error":{"message":"image media type is required","code":"invalid_request_body"}}

This above issue is already fixed last week. </comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 16, 2026 21:25
- Add isGeminiFamily() helper to detect Gemini models
- Add modelSupportsImageMimeType() to check image format support
- Filter out GIF images in geminiMessageConverter (conversation history)
- Filter out GIF images in Image component (new attachments)
- Add comprehensive unit tests for both changes

Co-authored-by: vijayupadya <[email protected]>
- Update error message to include all supported formats (HEIC, HEIF)
- Add null check for imageMimeType before upload to prevent undefined issues

Co-authored-by: vijayupadya <[email protected]>
- Extract supported MIME types to GEMINI_SUPPORTED_IMAGE_MIME_TYPES constant
- Add safe navigation operator for family property access
- Use constant in both image.tsx and geminiMessageConverter.ts
- Dynamically generate error message from constant for maintainability
- Consistent image format checking across codebase

Co-authored-by: vijayupadya <[email protected]>
- Use startsWith instead of includes for more precise Gemini detection
- Add getFormatFromMimeType helper to safely extract format from MIME type
- Eliminate code duplication in MIME type handling
- Add robust error handling for malformed MIME types

Co-authored-by: vijayupadya <[email protected]>
Copilot AI changed the title [WIP] Improve Gemini handling for image/gif support Filter unsupported image formats for Gemini models Jan 16, 2026
Copilot AI requested a review from vijayupadya January 16, 2026 21:38
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.

Gemini handling for image/gif needs improvement

2 participants