shiichan

The web_fetch Tool Arrives in the Agents SDK, Reading PDFs and Office Docs as Markdown

Hi everyone, it's Shii-chan!

Cloudflare Changelog developers.cloudflare.com

Agents can now be told to "go read this page" with a built-in tool in the Cloudflare Agents SDK. I'm so excited!

What was announced?

The Cloudflare Changelog announced a web_fetch tool for the Agents SDK. It reads webpages, and also PDFs and supported Office documents.

Under the hood it uses Workers AI Markdown Conversion to turn content into text the model can read.

The story so far

If you wanted an agent to read a webpage, you had to build the fetching, HTML cleanup, and PDF conversion yourself. Now the SDK bundles that into a tool you can hand to the agent!

What changes

The model gives a URL and gets the content back. The JSON result includes:

  • The page content
  • The final URL (after redirects)
  • The HTTP status
  • The content type

Long pages come back in smaller sections, and the model can use an offset to keep reading.

If you also give the agent the web_search tool, the model is told to use web_fetch to read the pages that search returns. Search and reading connect nicely!

Dive Deep

For sites that support Markdown for Agents, the tool requests Markdown directly instead of converting.

You control:

  • Which hosts the agent can fetch
  • Response size
  • Timeouts
  • Redirects

You need Agents SDK v0.28.0 or later, and you add the tool to a Pi Durable extension registry before opening the harness.

import { webFetchTool } from "agents/webfetch/pi";

this.registry.install({
  name: "web-tools",
  tools: [webFetchTool({ binding: this.env.AI })],
});

The SDK also includes adapters for AI SDK and TanStack AI. Without a model call, you can import fetchWeb(), windowWebFetchPage(), and renderWebFetchPage() from agents/webfetch. Direct fetching needs neither a Durable Object nor a browser.

The announcement doesn't list default numbers for size or timeouts, or which Office formats are supported.

Wrap-up

  • A web_fetch tool is now in the Agents SDK (v0.28.0 or later)
  • Reads webpages, PDFs, and supported Office documents as Markdown
  • Long pages can be continued with an offset
  • Hosts, size, timeouts, and redirects are configurable
  • Pairs with web_search for a full search-and-read flow

If you're building research-style agents on Cloudflare, this one's for you!