fix(broker): pass message.images through ai.chat for image-generation #68

Merged
mik-tf merged 1 commit from development_mik into development 2026-05-10 19:33:24 +00:00
Owner

Adds images: Option<Vec<ResponseImage>> to providers::types::Message, threaded from OpenRouter ApiMessage and the OpenAI provider, so image-output models round-trip cleanly through ai.chat.

Without this fix, herolib_ai::image_generation::parse_all_images errors "No images in response" on every image-gen call (e.g. google/gemini-3.1-flash-image-preview) because serde silently drops the unknown images field on deserialize.

Verified locally end-to-end with the matching hero_slides bucket-C PR: full slide generation through the broker produces a real PNG (≈1.3 MB) and the slides metadata correctly records the ADR-0007 inputs-hash snapshot.

Refs:

Signed-off-by: mik-tf

Adds `images: Option<Vec<ResponseImage>>` to `providers::types::Message`, threaded from OpenRouter ApiMessage and the OpenAI provider, so image-output models round-trip cleanly through `ai.chat`. Without this fix, `herolib_ai::image_generation::parse_all_images` errors `"No images in response"` on every image-gen call (e.g. `google/gemini-3.1-flash-image-preview`) because serde silently drops the unknown `images` field on deserialize. Verified locally end-to-end with the matching hero_slides bucket-C PR: full slide generation through the broker produces a real PNG (≈1.3 MB) and the slides metadata correctly records the ADR-0007 inputs-hash snapshot. Refs: - https://forge.ourworld.tf/lhumina_code/hero_slides/issues/54 - https://forge.ourworld.tf/lhumina_code/hero_slides/pulls (sister PR landing the slides side) Signed-off-by: mik-tf
fix(broker): pass message.images through ai.chat for image-generation models
Some checks failed
Build and Test / build-and-test (pull_request) Failing after 3s
8e518c9adc
OpenRouter image-output models (e.g. google/gemini-3.1-flash-image-preview,
google/gemini-3-pro-image-preview) return
`message.images: [{type:"image_url", image_url:{url:"data:image/png;base64,..."}}]`
in chat completions. The broker's typed `Message` struct had no `images`
field, so serde silently dropped them on deserialize. The subsequent
re-serialization in handle_ai_chat (openrouter shape) returned response
bodies without `images`, and downstream
`herolib_ai::image_generation::parse_all_images` errored "No images in
response" — breaking every slide.generate call.

Adds `images: Option<Vec<ResponseImage>>` to providers::types::Message
and threads it through ApiMessage (openrouter.rs) and the OpenAI
provider Message constructor.

Verified end-to-end locally: hero_slides generates PNGs via Gemini
Flash Image preview through this broker, with metadata round-tripping
the ADR-0007 inputs-hash snapshot.

Refs: lhumina_code/hero_slides#54

Signed-off-by: mik-tf
mik-tf merged commit f29a258648 into development 2026-05-10 19:33:24 +00:00
mik-tf deleted branch development_mik 2026-05-10 19:33:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker!68
No description provided.