Skip to content

fix(analyze): use AI SDK ImagePart format for vision screenshots#5566

Merged
DavertMik merged 1 commit into
codeceptjs:4.xfrom
gololdf1sh:fix/analyze-vision-image-format
May 15, 2026
Merged

fix(analyze): use AI SDK ImagePart format for vision screenshots#5566
DavertMik merged 1 commit into
codeceptjs:4.xfrom
gololdf1sh:fix/analyze-vision-image-format

Conversation

@gololdf1sh
Copy link
Copy Markdown

@gololdf1sh gololdf1sh commented May 15, 2026

Summary

  • Fix analyze plugin crash when vision: true — used OpenAI's image_url format instead of AI SDK's ImagePart format
  • generateText() from Vercel AI SDK expects { type: 'image', image, mediaType }, not { type: 'image_url', image_url: { url } }
  • Error was: Invalid prompt: The messages do not match the ModelMessage[] schema

Changes

lib/plugin/analyze.js lines 157-162:

- type: 'image_url',
- image_url: {
-   url: 'data:image/png;base64,' + base64EncodeFile(test.artifacts.screenshot),
- },
+ type: 'image',
+ image: base64EncodeFile(test.artifacts.screenshot),
+ mediaType: 'image/png',

The analyze plugin used OpenAI's `image_url` format for screenshot
attachments, but `generateText()` from the Vercel AI SDK expects
the `ImagePart` format (`type: 'image'`). This caused "Invalid prompt:
The messages do not match the ModelMessage[] schema" when vision: true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DavertMik DavertMik merged commit 55c5ce7 into codeceptjs:4.x May 15, 2026
10 checks passed
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.

2 participants