Skip to content

Commit 8f9db17

Browse files
authored
Merge pull request #83 from browser-use/alex/openai-compat-trust-user-modalities
fix(provider/openai-compatible): trust user-declared modalities, dont inject fake ERROR text
2 parents 06293d5 + cbd37a8 commit 8f9db17

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎packages/opencode/src/provider/transform.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,21 @@ function applyCaching(msgs: ModelMessage[], model: Provider.Model): ModelMessage
390390
}
391391

392392
function unsupportedParts(msgs: ModelMessage[], model: Provider.Model): ModelMessage[] {
393+
// @ai-sdk/openai-compatible is the user-configured proxy provider — there is
394+
// no models.dev entry to consult, so model.capabilities.input.{image,audio,
395+
// video,pdf} all silently default to false (provider.ts:1298-1304) unless
396+
// the user explicitly declares `modalities` in opencode.json. Replacing
397+
// every image/file part with an inline ERROR text part in that case is a
398+
// silent footgun: bcode strips the screenshot before the wire and the
399+
// model receives "ERROR: Cannot read image..." as if it came from the user,
400+
// producing nonsensical replies ("I can't see the image"). The honest
401+
// behavior is to forward the part — upstream returns a real provider error
402+
// if it truly can't handle it, which is far more debuggable than fabricated
403+
// capability text. Native providers (@ai-sdk/anthropic, @ai-sdk/openai,
404+
// @ai-sdk/google, @ai-sdk/amazon-bedrock) keep the check because models.dev
405+
// is authoritative for them.
406+
if (model.api.npm === "@ai-sdk/openai-compatible") return msgs
407+
393408
return msgs.map((msg) => {
394409
if (msg.role !== "user" || !Array.isArray(msg.content)) return msg
395410

0 commit comments

Comments
 (0)