downgradeUndecodableImages function
Replaces EVERY image block with undecodableUserImagePlaceholder /
undecodableToolImagePlaceholder, regardless of the model's declared
modalities. Used when a vision-capable backend rejected the request as
undecodable (Gemini's 400 Unable to process input image): the adapter
retries once with the images downgraded, so the turn survives and the
model can tell the user the image was unreadable.
Implementation
List<Message> downgradeUndecodableImages(List<Message> messages) {
return _replaceImages(
messages,
undecodableUserImagePlaceholder,
undecodableToolImagePlaceholder,
);
}