Skip to content

Web fetch

Fetches an HTTP(S) URL and returns its content. Two modes are available, configured at construction time via make_web_fetch / makeWebFetch:

  • agentic (default): HTML is converted to markdown and passed to an analyst agent that answers a prompt, so the full page never enters the main agent’s context. Use when targeted answers are needed about potentially large pages.
  • markdown: HTML is converted to clean markdown with scripts, styles, and noise stripped. Use when the agent needs full pages for reasoning.

The max_bytes / maxBytes parameter caps the HTTP response size (default 5 MiB); max_content_chars / maxContentChars caps the extracted content delivered to the model or analyst (default 50,000 characters). For mode='agentic' / mode: 'agentic', the factory also accepts a model for the analyst; agent.aux_modelagent.auxModel is used when none is supplied.

The Python tool delegates all networking to an httpx.AsyncClient. Use the make_web_fetch factory to supply a pre-configured client with custom timeouts, redirects, proxies, or caching.

Supported in: Node.js (TypeScript); Python (all platforms).

Example:

import { Agent } from '@strands-agents/sdk'
import { webFetch } from '@strands-agents/sdk/vended-tools/web-fetch'
const agent = new Agent({ tools: [webFetch] })
await agent.invoke('Summarize https://example.com/blog/post')

Reading the full page as markdown:

import { Agent } from '@strands-agents/sdk'
import { makeWebFetch } from '@strands-agents/sdk/vended-tools/web-fetch'
const webFetch = makeWebFetch({ mode: 'markdown' })
const agent = new Agent({ tools: [webFetch] })
await agent.invoke('Read https://example.com/docs and explain the architecture')

Tighter response cap with a dedicated analyst model:

import { Agent } from '@strands-agents/sdk'
import { makeWebFetch } from '@strands-agents/sdk/vended-tools/web-fetch'
import { BedrockModel } from '@strands-agents/sdk/models/bedrock'
const webFetch = makeWebFetch({
mode: 'agentic',
maxBytes: 1 * 1024 * 1024,
maxContentChars: 25_000,
model: new BedrockModel({ modelId: 'us.amazon.nova-micro-v1:0' }),
})
const agent = new Agent({ tools: [webFetch] })

📖 Full API Reference