[PR #4562] proper fix for image attachments #11020

Closed
opened 2026-02-16 18:15:48 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4562

State: closed
Merged: Yes


When reading text files via ReadTool, append any returned attachments (e.g., images) as synthetic file parts; otherwise fall back to the original file part.

  • Session handling (packages/opencode/src/session/prompt.ts):
    • ReadTool file handling:
      • After executing ReadTool for text/plain file inputs, push the text output and then:
        • If result.attachments exist, append them as synthetic file parts with filename defaulted to the original part’s filename.
        • Otherwise, append the original file part.
      • Ensures attachments (e.g., images) from tools are correctly attached to the message.
image image image
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4562 **State:** closed **Merged:** Yes --- > When reading text files via ReadTool, append any returned attachments (e.g., images) as synthetic file parts; otherwise fall back to the original file part. > > - **Session handling (`packages/opencode/src/session/prompt.ts`)**: > - **ReadTool file handling**: > - After executing `ReadTool` for `text/plain` file inputs, push the text output and then: > - If `result.attachments` exist, append them as synthetic `file` parts with `filename` defaulted to the original part’s filename. > - Otherwise, append the original file `part`. > - Ensures attachments (e.g., images) from tools are correctly attached to the message. <img width="1882" height="1073" alt="image" src="https://github.com/user-attachments/assets/5009c328-64bc-43d6-9aa2-f47685c6d408" /> <img width="1882" height="1073" alt="image" src="https://github.com/user-attachments/assets/8302f4e1-c1da-4761-ba43-8a20df4dc707" /> <img width="1882" height="1073" alt="image" src="https://github.com/user-attachments/assets/7b35888a-4a5a-4729-8d0d-0f50fe6ded40" />
yindo added the pull-request label 2026-02-16 18:15:48 -05:00
yindo closed this issue 2026-02-16 18:15:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11020