anomalyco / anomalyco/opencode

Gemini image models: generated images are discarded, never reach the session

Open
#41,467 0 comments 0 reactions 1 assignee View on GitHub

@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:

  1. packages/llm/src/protocols/gemini.ts — the response decoder handles text and functionCall; inlineData falls through the loop and is dropped. There is also no file variant in the LLMEvent union to carry it.
  2. packages/opencode/src/session/processor.ts — the stream handler has cases for text-*, reasoning-*, tool-*, step-*, and finish, but none for media, so nothing would be persisted even if the event existed.
Repro
  1. Configure a Gemini image model, e.g. google-vertex/gemini-2.5-flash-image, with responseModalities: ["TEXT", "IMAGE"] in the model options (required, or Vertex returns text only).
  2. Ask it to generate an image.
  3. The reply is text-only and no file part 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 v2 branch. dev is unaffected by that PR — the branches have diverged and packages/opencode does not exist on v2.
Version

1.18.15 (dev)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.