anomalyco / anomalyco/opencode
Gemini image models: generated images are discarded, never reach the session
Open
@jlongster is already working on this.
Since Aug 10, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Bug
Images generated by Gemini image models are silently discarded. The model returns the image, the request is billed, and the user sees only the assistant's text ("Here is the image you asked for") with nothing attached.
Cause
Gemini returns generated media as inlineData parts. Two gaps in the pipeline:
packages/llm/src/protocols/gemini.ts— the response decoder handlestextandfunctionCall;inlineDatafalls through the loop and is dropped. There is also nofilevariant in theLLMEventunion to carry it.packages/opencode/src/session/processor.ts— the stream handler has cases fortext-*,reasoning-*,tool-*,step-*, andfinish, but none for media, so nothing would be persisted even if the event existed.
Repro
- Configure a Gemini image model, e.g.
google-vertex/gemini-2.5-flash-image, withresponseModalities: ["TEXT", "IMAGE"]in the model options (required, or Vertex returns text only). - Ask it to generate an image.
- The reply is text-only and no
filepart exists on the assistant message, but the assistant message records image-sized output token usage.
Note: on dev you also need an agent with permission: {"*": deny} to get past #41464, since tool definitions otherwise make Vertex reject the request outright.
Related
- #40126 fixes this on the
v2branch.devis unaffected by that PR — the branches have diverged andpackages/opencodedoes not exist onv2.
Version
1.18.15 (dev)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.