anomalyco / anomalyco/opencode
[Bug] tool-result image attachments are re-fed to text-only models
Open
@nexxeln is already working on this.
Since Aug 19, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Expected Behavior\nTool-result image attachments should not be sent back to models that do not support image input. The image should be downgraded to a safe text placeholder or otherwise stripped so the session can continue.\n\n## Current Behavior\nWhen a tool returns an image attachment, text-only models can receive a file/media part and fail with errors like: .\n\n## Steps to Reproduce\n1. Use a tool that returns an image attachment (for example an image generation tool).\n2. Run the session with a model whose is false.\n3. The image attachment is projected back into the model input and the run fails.\n\n## Root Cause\n decides whether tool-result media can be forwarded using provider-specific heuristics instead of the model capability flags. The current path can preserve media for models that are text-only, which makes the downstream model input invalid.\n\n## Suggested Fix\nGate tool-result media forwarding on / , and downgrade unsupported media to a text placeholder instead of a file attachment.\n\n## Verification\n- Added a regression test covering unsupported image tool-result media for a text-only model.\n- Added a regression test covering unsupported PDF tool-result media.\n- Existing Bedrock PDF case still preserves PDF media for a PDF-capable model.\n\n## Notes\nThe repo currently reports the session error as a model input failure, but the underlying bug is in opencode's media projection path, not the user tool itself.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.