Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: OpenCode V2 image-generation results are reduced to empty text and not displayed #21746

Closedsauravhiremath(GitHub profile, opens in a new tab) opened this issue 4 comments

Before submitting

  • I searched existing issues and did not find an exact OpenCode duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server — OpenCode V2 provider adapter / tool-result attachments

Steps to reproduce

  1. Use T3 Code Nightly with OpenCode V2 and an OpenAI Responses-capable model that can run the hosted image_generation tool. The observed model was gpt-6.1-sol through a custom relay.
  2. Send: Generate an image of an orca holding an apple, animated.
  3. Let the turn complete. The observed run used native image_generation.
  4. Inspect the conversation and compare T3's stored activity with the corresponding OpenCode session message.

Expected behavior

A successful tool result containing an image is visible in the conversation, with a way to view or save it. The image remains available when the thread is reopened or the provider session is reconciled. This should not require the model to repeat the image in a final Markdown reply.

Actual behavior

Image

The image was actually generated. The stored OpenCode assistant message contains a completed tool result with a PNG data URI. Decoding that URI recovered a valid image of the requested scene:

  • PNG dimensions: 1312 × 1199.
  • Decoded size: 2,434,757 bytes.
  • The image was recovered from the existing message; no repeat generation was needed.

OpenCode's result shape, with bytes and unrelated metadata omitted:

{
  "type": "tool",
  "name": "image_generation",
  "executed": true,
  "state": {
    "status": "completed",
    "input": {},
    "content": [
      {
        "type": "file",
        "uri": "data:image/png;base64,<omitted>",
        "mime": "image/png"
      }
    ]
  }
}

The corresponding T3 activity contains:

{
  "toolName": "image_generation",
  "input": {},
  "output": ""
}

Source investigation

The same text-only conversion is present on current main at 5307c233b1f0ae72b8894dd39d94019aaf9e7cb8. Downloaded source files were checked against that commit's blob hashes.

In packages/provider-opencode/src/server/v2/adapter.ts:

  1. textOf, lines 502–503, keeps only type === "text" blocks.
  2. The live session.tool.success handler, lines 1998–2018, passes textOf(event.data.content) to the completed tool output.
  3. History backfill, lines 2431–2445, also uses textOf(part.state.content).

Thus a file-only result becomes an empty string before client rendering. A mixed text/file result also loses its file block. A small local check of this conversion confirmed both cases; the full repository test suite was not run, and no fix was implemented.

Both the live-event and saved-history paths appear to need a way to retain supported file/image results through T3's media/attachment handling. Large base64 bodies should not simply be copied into ordinary timeline text. Useful test cases include file-only results, mixed text/file results, native hosted tools, history backfill/reconnect, and a settled turn with no assistant text.

Configuration checked

The OpenCode provider guide supports OpenCode 2.0.18 and newer; this environment uses 2.0.29. Neither that guide nor the OpenCode provider settings schema exposes an image-output switch. The text-only conversion above is unconditional, so this does not appear to be a missing image-display setting.

Impact

Major degradation: generation succeeds, but its only deliverable is hidden and the successful status gives no indication of the missing output. Observed once for this exact OpenCode reproduction; repeat live generation, other clients, and a patched build were not tested.

Version or commit

  • T3 Code Nightly: 0.1.1-nightly.20261018.3331, verified from the installed app's Info.plist.
  • OpenCode: v2.0.29.
  • Source gap checked on main at 5307c233b1f0ae72b8894dd39d94019aaf9e7cb8.

Environment

macOS 27.0 (26A428), arm64, desktop app, OpenCode provider, gpt-6.1-sol through a custom relay, full-access mode. Observation date: 2026-10-19.

Workaround

Recover the PNG data URI from the stored OpenCode message, save it to a local file, and return an explicit Markdown image or a file link. The recovered PNG was checked and a Markdown embed was sent, but its final display in the user's client was not independently verified. No additional relay or model-capability overrides were needed to recover the bytes.

  • #15420: Codex native imageGeneration output is missing unless the reply embeds it.
  • #19059: Codex image blocks returned through functions.exec are invisible.
  • #2398: earlier Codex image-generation support report, now closed.

These describe similar symptoms, but this report identifies the distinct OpenCode V2 Tool.FileContent → text-only output path. Targeted searches for image_generation, OpenCode image output, and textOf found no exact existing issue.


Prepared by an AI agent (GPT-6.1 Sol through OpenCode), at the affected user's request, using their screenshot, stored T3/OpenCode records, recovered image bytes, and upstream source.

  1. Note

    Grok responding on behalf of Julius.

    Thanks for the detailed report. Confirmed on current main.

    textOf keeps only text blocks (packages/provider-opencode/src/server/v2/adapter.ts:502-503). Both the live tool result (adapter.ts:2012-2016) and history backfill (adapter.ts:2442) use it, so a file-only result is stored as an empty output and the image is lost before the client sees it.

    This is the OpenCode side of the gap tracked in #15420 for Codex. In both cases the generated image only shows up if the final reply embeds it. The data differs, though. Codex leaves a saved file, and OpenCode returns the image bytes inline, so this one stays a separate issue.

    Accepting this as a bug.

  2. juliusmarminge added labelsaccepted

  3. juliusmarminge added labelsbug

  4. juliusmarminge added labelsvia-triage

  5. juliusmarminge added labelsneeds more info

  6. juliusmarminge removed labelsneeds more info

  7. Do we have any update on this? I see we have a PR open for this - lemme know if any help needed from me

  8. Thanks for checking in. #21796 is open for this: it keeps image blocks (raster images sent as base64 data: URIs) in the V2 tool results, both live and when history is backfilled, and the tests cover interleaved text and images. It's waiting on review.

  9. Thanks for the detailed report! #30389, merged as d51bc58f, preserves OpenCode image results in both live output and history so they can be viewed in tool details.

  10. juliusmarminge closed this

Sign in to join this conversation.