Skip to content

session: provider image rejection bricks session — generic 400 error, no recovery path #52042

Description

@felixcse

Description

When a custom OpenAI-compatible provider's model rejects image input, a pasted image bricks the session. Every subsequent request replays the image with the full session history and fails with the same generic Error: Provider request failed with HTTP 400. The provider's actual error body is never surfaced, nothing identifies the image as the cause, and there is no in-app recovery. Switching the session to a model that accepts images revives it (undocumented, undiscoverable workaround); switching back re-breaks it.

Distinct from the tool-result path in #39824, #43388, #41163, and the closed #51873: here the image is a user attachment on a custom provider, so the model capability gate never fires — custom models carry no modality metadata, and the image is sent through to a provider that rejects it. A config field to declare input modalities for custom provider models would let the existing gate handle this client-side, and would also cover the inverse case in #43392.

The provider rejection was verified independently of OpenCode — a direct curl to the endpoint with a standard OpenAI image_url content part (both a real screenshot and a 1×1 control pixel) returns 400 with <model> is not a multimodal model. So the request format is fine; the issue is OpenCode's handling of the rejection: an opaque repeated error with no guided recovery.

Plugins

None

OpenCode version

2.0.19 — behavior verified identical on 2.0.16 and 2.0.19

Steps to reproduce

  1. Configure a custom OpenAI-compatible provider whose model does not accept image parts (e.g. a gateway fronting a text-only LLM)
  2. Start a chat with that model
  3. Paste an image into the chat and send
  4. The request fails: the chat shows only "Error: Provider request failed with HTTP 400". The provider's response body — which names the actual cause — is not shown
  5. Send any new message, even plain text like "hey": it fails with the same generic error, because the image is replayed with the full session history on every request
  6. Restart opencode and resume the session: draining fails the same way (Failed to drain Session in the logs)
  7. Switch the session's model to one that accepts images: the session revives and works. Switch back to the text-only model: it fails again

Screenshot and/or share link

Server log, repeated on every resume attempt:

ERROR message="Failed to drain Session" cause="AI.Error: <model> is not a multimodal model"
ERROR message="Failed to drain Session" cause="AI.Error: Provider request failed with HTTP 400"

The failed assistant message persists with finish: "error" and error.type: "provider.invalid-request" — the error data exists, it is just not surfaced usefully in the chat UI.

Operating System

macOS (Darwin 25.6.0, arm64)

Terminal

VS Code integrated terminal (zsh)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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