Repository navigation
Commit 3c5df1e
committed
fix(mimo): flatten list-type tool message content to string (upstream #32613)
Root cause finally verified via upstream issue anomalyco/opencode#32613
'Xiaomi MiMo rejects list-type tool message content (400 text is not set)':
Xiaomi MiMo API requires role:'tool' message content to be a plain string,
NOT a list of content parts. MiMo accepts multimodal content in user/assistant
messages but strictly rejects list-type content in tool messages. The OpenCode
Go gateway passes list-type content through unchanged, so we must flatten it
client-side.
Verified in user log (2026-07-25 13:05):
messages=3 payloadBytes=151626 -> 200 OK (tool result without image)
messages=5 payloadBytes=426159 -> 400 Upstream request failed
(same + tool result WITH image_url list-type content)
Previous 4 fix attempts (top-level guard, history trim, reasoning echo, TDZ)
were all red herrings — the real issue is the tool message shape itself.
Fix: for MiMo family, when a tool result contains image parts, emit plain
string content by joining text parts and replacing each image with a short
placeholder note (the model cannot see tool images on MiMo upstream anyway).
Other providers (Kimi, GLM-5.1, MiniMax, Qwen) keep the multimodal array
because they accept list-type tool content.
Upstream PR anomalyco/opencode#32966 exists but was closed by automated
cleanup before merge, so this workaround is necessary until the gateway
handles the translation.
- src/extension.ts: convertMessage() tool-result branch gates multimodal
array on model family; MiMo gets flattened string.1 parent fb9f824 commit 3c5df1e
1 file changed
Lines changed: 30 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3383 | 3383 | | |
3384 | 3384 | | |
3385 | 3385 | | |
3386 | | - | |
3387 | | - | |
3388 | | - | |
3389 | | - | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
3390 | 3416 | | |
3391 | | - | |
3392 | | - | |
3393 | 3417 | | |
3394 | 3418 | | |
3395 | 3419 | | |
| |||
0 commit comments