anomalyco / anomalyco/opencode

bug: tool-result media 400s whole request for models without attachment capability

Open
#41,163 3 comments 1 reaction 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 8, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Problem

supportsMediaInToolResult in message-v2.ts returns true unconditionally for @ai-sdk/anthropic and @ai-sdk/openai npm packages. For models with attachment: false (no vision — e.g. GLM-5.2 served through an Anthropic-compatible endpoint), image/PDF attachments from tool results stay inside the tool result and are re-sent on every subsequent turn as part of history replay. The provider then rejects the entire request with a 400 (e.g. Model ... does not appear to support image inputs.), killing the response.

User-visible symptom: a session where a tool returned a screenshot works fine until a later turn — then every response dies with Bad Request: Model ... does not appear to support image inputs., even when the user sends only text.

Why this is a regression: with @ai-sdk/openai-compatible, media was extracted to a user message where unsupportedParts() converted it to a graceful text note ("ERROR: Cannot read image ... Inform the user.") and the model replied normally.

Expected behavior

Media from tool results should be extracted to a user message (degraded gracefully by unsupportedParts()) when the model's attachment capability is false — regardless of the SDK npm package.

Environment

  • opencode version: 1.18.14+ (reproducible on dev)
  • Model: any with attachment: false served via @ai-sdk/anthropic or @ai-sdk/openai

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.