Skip to content

fix(tools): web_fetch saves binary content (images, PDFs) as .txt files #386

Description

@Aaronontheweb

Problem

web_fetch with Format: "raw" downloads binary content (images, PDFs) but saves it with a .txt extension and treats it as text. A 2MB PNG becomes a mangled .txt file that attach_file can't deliver to Slack as an image.

Discovered in session D0AC6CKBK5K/1774227325.028479 — user asked to download a blog image and send it back. The image was fetched successfully but saved as headl-1774230585.txt (2MB). The LLM then went silent because it couldn't figure out how to attach a .txt file as an image.

Fix

Check Content-Type response header:

  • image/* → save with correct extension (.png, .jpg, .gif, .webp)
  • application/pdf → save as .pdf
  • Other binary types → preserve original extension from URL
  • text/html, text/plain → current behavior (save as .html or .txt)

Impact

Blocks the "download and send back" workflow via Slack. The attach_file tool needs a correctly-typed file to deliver to the channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions