Skip to content

VS Code extension: pasted images break multi-turn chat with 400 invalid_request_error (content sent as image_url array instead of string) #31870

Closed as not planned

Description

@st-arafat

Description

When pasting an image into the opencode VS Code extension chat and continuing a multi-turn conversation, the request fails with a provider 400 invalid_request_error. The pasted image is serialized as an image_url content-array on a history message, but the upstream expects that message's content to be a plain string.

The exact same model + provider + config works correctly in the opencode TUI, which isolates this to a client-side (extension) request-serialization issue rather than a model/provider limitation.

Environment

  • opencode VS Code extension: 0.0.13 (latest on the marketplace)
  • VS Code: 1.123.2
  • Provider / model: opencode-go / kimi-k2.6
    • The local model registry confirms vision support: attachment: true, modalities.input: [text, image, video]

Steps to reproduce

  1. In the VS Code extension, select model opencode-go / Kimi K2.6.
  2. Paste an image and ask a question (e.g. "what is this").
  3. Continue the conversation across several turns, keeping/pasting the image in context.
  4. After a few turns, the request fails.

Actual result

Sorry, your request failed. Please try again.
Reason: Request Failed: 400
{"error":{"object":"error","type":"invalid_request_error","code":"invalid_request_error",
"message":"Error from provider: 2 request validation errors:
 Input should be a valid string,
 field: 'messages[8].content',
 value: [{'image_url': {'url': 'data:image/png;base64,iVBORw0KGgo...'}}]"}}

Key detail: the failure is on messages[8] (a history message), and its content is being sent as [{ image_url: { url: "data:image/png;base64,..." } }]. The upstream rejects this because it expects content to be a string for that message position/role.

Observed side effect earlier in the same thread: because the image isn't delivered in a valid shape, the model hallucinated an unrelated description and, on a follow-up, replied "I don't see any image in your message" — consistent with the image never reaching the model correctly.

Expected result

Images should be serialized into the request the same way the opencode TUI does it (which works), so multimodal models like Kimi K2.6 receive the image as valid content and multi-turn image conversations don't 400.

Notes / likely cause

  • The TUI and the extension share the same opencode server, opencode.json, provider, and model — only the extension's request building differs, which isolates the bug to the extension client.
  • It looks like the extension re-attaches the pasted image as an image_url content-part into prior (history) messages, rather than:
    • keeping image parts only on the message that originally carried them, and/or
    • emitting string content for messages where the upstream schema requires a string (e.g. assistant/tool roles), and/or
    • normalizing/dropping historical image parts the way the TUI does.
  • Repro appears tied to multi-turn state (fails at messages[8]), not the first message.

Workarounds

  • Use the opencode TUI for image tasks (works reliably with the same setup).
  • In the extension, paste the image in a fresh, single-turn chat.

Operating System

macOS

Terminal

VS Code extension (not a terminal)

Activity

  1. github-actions commented on Aug 11, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions