Skip to content

fix(core): only send png, jpeg and webp images to xAI - #53787

Merged
neriousy merged 1 commit into
anomalyco:v2from
Jaaneek:xai-gif-guard
Oct 7, 2026
Merged

neriousy merged 1 commit into
anomalyco:v2from
Jaaneek:xai-gif-guard

Conversation

@Jaaneek

@Jaaneek Jaaneek commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #53786

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

xAI only accepts PNG, JPEG and WebP images. Any other image type, like a GIF, gets a 400 invalid_image. The GIF stays in the history, so every later turn fails too and the session is stuck.

For the xAI provider, this swaps other image types for the note v2 already uses when a model can't read some media (Cannot read "x.gif" (this model does not support image/gif input). Inform the user.). It covers user attachments and read-tool results. It runs when the request is built, so stored messages are unchanged and already stuck sessions work again. Other providers are unchanged.

How did you verify your code works?

  • New test in session-model-request.test.ts; it fails without the change. bun run test and bun typecheck pass in packages/core.
  • Live on grok-4.7. Before: attaching a GIF, the follow-up turn, and reading the GIF with the read tool all got 400. After: all three answer and no GIF is sent to xAI. A PNG is still sent and described correctly.

Screenshots / recordings

Input GIF:

Input GIF: a red square and a blue circle

Before: the GIF turn and the follow-up both fail with 400.

Before: both turns fail with 400 invalid_image

After: the model says it can't read the GIF, and the follow-up answers.

After: the model says it cannot read the GIF and the follow-up answers OK

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

xAI rejects other image types such as GIF with a 400 invalid_image. The
image stays in the session history, so every later turn fails too.
Replace those images with the existing unsupported-media error text, for
both user attachments and tool results.
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@neriousy
neriousy merged commit 31bdd8e into anomalyco:v2 Oct 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants