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
{{ message }}
Repository navigation
bug: --file flag hardcodes all attachments as text/plain, breaking image/vision uploads #25353
When attaching files with the --file / -f flag, all files are hardcoded as text/plain regardless of their actual type. This means image files (PNG, JPEG, WebP, etc.) are injected as raw binary text garbage into the prompt instead of being base64-encoded and passed as proper data:image/... URLs to the LLM.
Root cause
In packages/opencode/src/cli/cmd/run.ts (~line 323):
Every file that is not a directory gets text/plain. The downstream pipeline already handles non-text MIME types correctly (reads binary, base64-encodes, creates data: URLs at session/prompt.ts line 1155) — it is simply never reached.
Impact
Image attachments are unusable via --file — vision models receive garbage
Audio/video/PDF attachments would have the same problem
The codebase already has extension-based MIME detection (getImageMimeType() in file/index.ts) but it is not used at the CLI entry point
Proposed fix
Replace the hardcoded text/plain fallback with a helper that maps known file extensions to MIME types, defaulting to text/plain for unknown extensions.
Environment
OpenCode version: 1.14.28
Provider: ollama (vision models like gemma4, qwen3-vl)
Activity
github-actions commentedon May 1, 2026
This issue might be a duplicate of existing issues. Please check:
run --filehardcodestext/plainMIME type for all files #16723: Same root cause —run --filehardcodestext/plainMIME type for all non-directory files--fileflag attaches images with incorrect MIME type, breaking multimodal supportPlease review those issues and consider closing this one if they cover the same problem.
fix(cli): detect MIME type for --file flag instead of hardcoding text…
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.