Skip to content

fix(platform): retry a gateway's empty image list over chat - #5505

Open
yannickmonney wants to merge 2 commits into
mainfrom
fix/gateway-image-empty-list-over-chat
Open

yannickmonney wants to merge 2 commits into
mainfrom
fix/gateway-image-empty-list-over-chat

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Fixes #5498.

What failed

generate_image with gemini-3.1-flash-image through the custom provider "Apps with love" (an AI gateway) failed with "the provider answered without an image". That message comes from the images wire (openai-images): the gateway answered POST /images/generations with HTTP 200 and a data list that holds no b64_json item. Because the answer was a 200, the chat-completions fallback from v0.5.98 never ran.

Why

Bifrost (2.6.0, core/providers/gemini/images.go, ToBifrostImageGenerationResponse) now serves the images API for its Gemini backend. On 2026-11-03 one gateway's Gemini backend answered that API with 404, which sent Tale to chat completions, where the model drew. Bifrost asks Gemini's generateContent with responseModalities: [IMAGE] and copies only the answer's inlineData parts into data. The list starts empty, so a candidate that holds text but no inline image comes back as {"data": [], "usage": …}, and the model's words are dropped. Tale treated every 200 without a usable image as a billed answer that is never asked again.

The gateway's own logs would show why Gemini drew nothing for this prompt. Tale cannot see them. Over chat completions, the same model either draws or says why it didn't.

Change

  • image_wire.ts: an images-API reply whose list carries nothing at all (no image data and no link) throws ImageReplyError with withoutImage: true. A link in url is now reported as a link (the chat wire already did this), and a data: URL in url is read as the image it is. A reply whose image data doesn't decode, or comes in a format Tale doesn't store, is not marked.
  • image_generation.ts: for a model with a fallback wire (an images API Tale has not verified, such as a gateway), a withoutImage answer is asked again over chat completions, like a refusal of the API. Both replies' charges are booked, whether the retry succeeds or fails. A chat reply that serves the request makes chat the first wire for 24 h, as before. Verified providers (OpenAI, OpenRouter) carry no fallback and are unchanged.
  • Docs (en/de/fr, admin and self-hosted providers pages) and the automation reference row updated to match.

Trade-off

An empty answer that Gemini declined for its content is now asked over chat too, so it is billed twice. The first reply is text only, with no image output tokens, so it costs little. The admission hold is per image and does not cover the second call. The settle books the actual spend.

Tests

bunx vitest --run --configLoader runner --project server backend/core/lib/providers/ backend/domains/agent_tools/ backend/core/node_only/sandbox/: 57 files, 1503 tests passed. tsc --noEmit (services/platform), oxlint --type-aware on the changed files, oxfmt --check, lint:manual, lint:conflicts and opengrep all came back green.

New tests:

  • An empty list from the images API is asked over chat completions. Both charges are booked, and chat is asked first on the next call.
  • When neither wire draws, the error reports what both answered and books both charges.
  • A verified provider's empty list is not retried.
  • A link, an SVG, undecodable data or a refusal is not marked withoutImage.
  • A data: URL in url is read as an image.

…hing

A gateway's image model failed with "the provider answered without an
image" (#5498): gemini-3.1-flash-image through a Bifrost gateway. Bifrost
now serves the images API for its Gemini backend (it answered 404 on
2026-11-03, which sent Tale to chat completions, where the model drew), and
it relays a Gemini answer that holds no inline image as an empty data list
with the model's words dropped. Tale took that list as a billed answer and
never asked again, so the call failed with nothing to say why.

On a model whose images API Tale has not verified, an images reply whose
list carries nothing at all (no image data, no link) is now asked again over
chat completions, like a refusal of the API: there the model draws, or
Tale quotes what it wrote instead. Both replies' charges are booked, on
success and on failure, and a chat reply that serves makes chat the first
wire for a day as before. A reply with image data that does not decode, an
unstored format or a link is still never asked again. A link in an images
reply is now told as a link, and a data URL in its url field is read as the
image it is.
@yannickmonney yannickmonney changed the title fix(platform): ask a gateway's image model over chat when it drew nothing fix(platform): retry a gateway's empty image list over chat Nov 23, 2026

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.

Image generation with gemini-3.1-flash-image fails: provider answered without an image

1 participant