[PR #13331] feat(tool): return image attachments from webfetch #14617

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

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

State: closed
Merged: Yes


tl;dr: allows the WebFetch tool to detect binary return types & return images as filetypes.

image

Summary

  • add binary image handling to the webfetch tool so image responses are returned as file attachments with base64 data URLs, matching the read tool attachment behavior
  • harden content-type detection by normalizing/parsing MIME values before image checks to handle mixed casing and charset suffixes safely
  • add focused webfetch tool tests for image attachment returns, svg passthrough behavior, and non-image text responses

Validation

  • bun run typecheck (packages/opencode)
  • bun test ./test/tool/webfetch.test.ts (packages/opencode)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13331 **State:** closed **Merged:** Yes --- tl;dr: allows the `WebFetch` tool to detect binary return types & return images as filetypes. <img width="1059" height="1171" alt="image" src="https://github.com/user-attachments/assets/e62dd363-28b3-41a7-9d11-e2db68c997ac" /> ## Summary - add binary image handling to the `webfetch` tool so image responses are returned as file attachments with base64 data URLs, matching the `read` tool attachment behavior - harden content-type detection by normalizing/parsing MIME values before image checks to handle mixed casing and charset suffixes safely - add focused `webfetch` tool tests for image attachment returns, svg passthrough behavior, and non-image text responses ## Validation - bun run typecheck (packages/opencode) - bun test ./test/tool/webfetch.test.ts (packages/opencode)
yindo added the pull-request label 2026-02-16 18:19:23 -05:00
yindo closed this issue 2026-02-16 18:19:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14617