Skip to content

Cloudflare gives agents a web fetch tool with built-in pagination

Agents SDK 0.28.0 adds a beta web_fetch tool that converts HTML, PDF and Office documents to Markdown and paginates long pages automatically.

Source: Cloudflare

Cloudflare’s Agents SDK 0.28.0 ships a beta web_fetch tool that lets an agent read a URL without you writing the fetch-and-clean-up code yourself. It converts HTML, PDF and Office documents to Markdown through Workers AI, pretty-prints JSON, and requests Markdown directly from sites that support the Markdown for Agents protocol.

The tool hands the model up to 20,000 characters per call by default, wrapped in an untrusted_web_content tag, and returns a suggested offset so the model can page through longer documents instead of truncating them. You install it from agents/webfetch/pi, agents/webfetch/ai-sdk or agents/webfetch/tanstack-ai depending on your harness, and pass it a Workers AI binding:

import { webFetchTool } from "agents/webfetch/ai-sdk";

const tools = { web_fetch: webFetchTool({ binding: env.AI }) };

Access controls are built in: allowedHosts, blockedHosts, a 2,000-character URL limit, a 5,000,000-byte cap, and private IPs blocked by default. It also rejects credentials embedded in URLs and HTTPS-to-HTTP redirects.

Why it matters: if you’re building an agent on Cloudflare that needs to read arbitrary web pages, this removes a chunk of boilerplate around document conversion, pagination and host allowlisting that most people were writing by hand.

The caveat: it’s beta, and Cloudflare says the API may still change.

Share

Related reading

More from The Wire

All briefs