You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a Read result includes an image attachment whose bytes are not a valid image, provider adapters can throw an image decoding error and the session gets stuck failing on following turns.
Plugins
None
OpenCode version
v1.2.15 (also reproducible on current dev branch before this fix)
Steps to reproduce
Attach or read a file that is labeled as an image (image/png, image/jpeg, image/gif, or image/webp) but contains invalid bytes/base64.
Send a prompt so the message is transformed and forwarded to the model provider.
Observe provider error: "The image data you provided does not represent a valid image..." and subsequent turns continue failing.
Additional reproduction scenario: file extension vs actual MIME type mismatch
@thdxr I hit the exact same "poisons subsequent turns" issue, but with a more specific root cause worth noting:
What happened
Used bash tool to call Gemini API for image generation. Gemini returned mimeType=image/jpeg data.
The AI-written script saved the JPEG data with a .png extension: /tmp/nano_banana_test.png
AI then called the read tool on this .png file
OpenCode's read tool correctly detected the attachment mime as image/jpeg (stored correctly in the DB with "mime":"image/jpeg" and "url":"data:image/jpeg;base64,...")
However, when assembling the API request for the next turn, OpenCode used media_type: image/png (inferred from the .png file extension), overriding the correctly detected mime
Anthropic API returned 400: "The image was specified using the image/png media type, but the image appears to be a image/jpeg image"
Session permanently stuck - every subsequent turn re-sends the poisoned tool_result
Key insight
The bug is in the provider adapter layer: when converting stored attachments into API request payloads, OpenCode re-infers the media type from the file path extension instead of using the already-correct mime field from the stored attachment data.
Environment
OpenCode v1.2.27
macOS (arm64)
Anthropic claude-opus-4-6
Workaround: manually cleaned the SQLite DB (opencode.db) - removed the image attachment from the part data and deleted the error messages
Activity
github-actions commentedon Feb 26, 2026
This issue might be a duplicate of existing issues. Please check:
kapaandyy commentedon Mar 23, 2026
Additional reproduction scenario: file extension vs actual MIME type mismatch
@thdxr I hit the exact same "poisons subsequent turns" issue, but with a more specific root cause worth noting:
What happened
mimeType=image/jpegdata..pngextension:/tmp/nano_banana_test.pngreadtool on this.pngfileimage/jpeg(stored correctly in the DB with"mime":"image/jpeg"and"url":"data:image/jpeg;base64,...")media_type: image/png(inferred from the.pngfile extension), overriding the correctly detected mime"The image was specified using the image/png media type, but the image appears to be a image/jpeg image"Key insight
The bug is in the provider adapter layer: when converting stored attachments into API request payloads, OpenCode re-infers the media type from the file path extension instead of using the already-correct
mimefield from the stored attachment data.Environment
opencode.db) - removed the image attachment from the part data and deleted the error messagesfix(read): reject unsupported image formats before sending to provider