Selling to coding agents instead?Go to Gauge Agents
Blogs

9 minSeptember 4, 2026Author:Evan DoyleEvan Doyle
How Claude Code Searches the Web

Claude Code does not have one generic internet tool. It has two different pipelines: WebSearch discovers pages, while WebFetch reads one page.

That distinction determines where the network request runs, what a website can observe, how much of a page reaches the main model, and which source controls apply along the way.

We traced both paths through a Claude Code source snapshot and compared them with Anthropic's public documentation. The implementation details below reflect the code as inspected on September 4, 2026 and may change in later releases.

WebSearch runs through an Anthropic-hosted search model and returns links plus findings, while WebFetch retrieves one page from the Claude Code harness and usually sends the converted Markdown through Haiku.

WebSearch finds URLs; WebFetch reads them

WebSearch WebFetch
Job Find relevant URLs Read one known URL
Where retrieval happens Anthropic's search backend The Claude Code harness
Input from main Claude Query, with optional domain filters URL and extraction prompt
What comes back Result titles, URLs, and search-model findings Usually a Haiku-produced answer about the page
Does it read the result pages? No Yes
What enters the main conversation A formatted search report Extracted answer, or raw Markdown in one special case
What the publisher can see Not a direct visit from the local Claude Code session A request with a Claude-User user agent

Anthropic's Claude Code tool reference confirms the central split: WebSearch returns titles and URLs but does not fetch the result pages; Claude follows up with WebFetch when it needs to read one.

How WebSearch works

When the main Claude model decides it needs current information, it calls WebSearch with a query. The tool also accepts either allowed_domains or blocked_domains, but not both.

From there, Claude Code starts a separate model request dedicated to the search. That request includes Anthropic's server-side web_search_20250305 tool with a hardcoded limit of eight searches. The search model can issue multiple queries, refine them, and write findings before returning control to the local harness.

The flow is:

  1. The main Claude model calls WebSearch.
  2. The Claude Code harness creates a separate search-focused model request.
  3. Anthropic's API executes up to eight backend searches on its own infrastructure.
  4. The API returns search-result blocks and text written by the search model.
  5. The harness extracts each result's title and URL, keeps the text findings, and formats both as a tool result.
  6. That complete tool result is added to the main Claude conversation.

The Claude web search API documentation describes the same server-side loop: the API runs the searches, supplies the results to Claude, and may repeat that process several times in one request.

The harness turns search blocks into a text report

The local harness turns the server response into plain text shaped like this:

Web search results for query: "tach python module dependency tool"

Links: [{"title":"FAQ - Tach - Gauge","url":"https://docs.gauge.sh/usage/faq/"}, ...]

Here's what I found on Tach:
[The search model's findings]

REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.

There may be several Links: arrays because one WebSearch tool call can contain several backend searches. Text findings can appear between or after them.

Claude Code preserves the result titles and URLs, but it does not pass the raw result pages into the main conversation. It also flattens the search model's prose into text. The main model therefore sees a research memo—links plus findings—not a browser session and not the full source documents.

The tool description separately instructs the main model to finish its answer with a Sources: section containing relevant URLs. That is why the links survive both the internal search turn and the final user-facing answer.

A search result does not send a request to your site

This matters for analytics. A page can appear in WebSearch without receiving a direct request from the developer's machine. The search is using Anthropic's backend, not opening every result through the local CLI.

If Claude needs details beyond the search model's findings, it must choose a URL and call WebFetch. Discovery and retrieval are two separate decisions.

How WebFetch works

WebFetch starts with a known URL and a prompt describing what Claude wants from it:

{
  "url": "https://example.com/docs/authentication",
  "prompt": "Extract the OAuth setup steps and required environment variables."
}

Unlike WebSearch, this request is implemented by the Claude Code harness. In a terminal session, the fetch originates from the machine running Claude Code. In a Claude Code web session, that harness is running in Anthropic's managed environment.

The pipeline is:

  1. Claude Code checks permission for the target domain.
  2. It sends only the hostname to Anthropic for a domain-safety preflight, unless that check has been disabled in settings.
  3. The harness requests the page directly, preferring text/markdown over HTML.
  4. If the server returns HTML, Claude Code converts it to Markdown with Turndown. Other text formats are kept as returned.
  5. Claude Code combines the Markdown with Claude's extraction prompt.
  6. A Haiku model processes that combined prompt.
  7. Haiku's answer—not usually the page itself—becomes the WebFetch tool result in the main conversation.

Anthropic calls this process "lossy by design". The extraction prompt controls which details survive. If Claude asks only for installation steps, an unrelated pricing paragraph can disappear even though it was present on the page.

WebFetch identifies itself as Claude Code

WebFetch sends an Accept header that prefers Markdown and a user agent shaped like:

Claude-User (claude-code/<version>; +https://support.anthropic.com/)

That makes WebFetch traffic distinguishable from a normal browser request. It also makes this path different from agents that fetch known URLs through shell curl; we documented that contrast in Does Codex Read llms.txt?.

WebFetch caps, caches, and redirects requests

The inspected implementation:

  • upgrades http:// URLs to HTTPS;
  • caps the HTTP response at 10 MB;
  • passes at most the first 100,000 characters of converted content to Haiku;
  • caches successful URL responses for 15 minutes, with a 50 MB total cache;
  • follows same-host redirects, including adding or removing www;
  • stops on a redirect to a different host and asks Claude to call WebFetch again for the new URL; and
  • cannot access authenticated or private pages unless another tool supplies that access.

The safety preflight is separate from the page fetch. Anthropic's data usage documentation says it receives the hostname only—not the full path or page content—and caches an allowed hostname for five minutes.

The 125-character quote rule

The most surprising part of WebFetch is the prompt sent to Haiku for ordinary domains.

It does not limit the output to 125 words. It instructs Haiku to enforce a strict 125-character maximum for direct quotes from each source document. The prompt makes a separate allowance for open-source software when its license is respected. It also tells the model that language outside quotation marks must not reproduce the source word for word and that song lyrics must never be reproduced.

That is a copyright-control instruction, not a 125-character cap on the whole answer. Haiku can still return a longer paraphrase. It is also a model instruction rather than a deterministic truncation step: Claude Code does not count characters after generation and cut the result at 125.

In concrete terms:

  • 125 characters, not 125 words
  • direct quotation, not total extracted information
  • per source document, not necessarily per response
  • enforced through the Haiku prompt, not a post-processing filter

Preapproval can bypass the permission prompt and Haiku

Claude Code contains a built-in set of code-related sites it treats as preapproved. In the inspected source, that list changes two parts of WebFetch behavior.

First, the domain can be fetched without the normal first-use permission prompt. This is a WebFetch exception only; it does not give shell commands unrestricted network access.

Second, the content-processing rules are relaxed:

  • If a preapproved URL returns text/markdown and contains fewer than 100,000 characters, Claude Code returns the page content directly. Haiku is skipped.
  • If the content is HTML, another format, or too long for that fast path, Haiku still processes it—but receives a permissive instruction to include relevant details, code examples, and documentation excerpts as needed. The 125-character quote instruction is absent.

So “preapproved” means more than “no permission dialog.” It can determine whether the main Claude model receives a summary or the page itself.

It does not mean Anthropic endorses, ranks, or prefers the product. The list is an implementation policy for code-related fetches.

The complete preapproved list

The source contains 89 entries and 88 unique targets. learn.microsoft.com appears twice because it is listed under both programming languages and cloud tooling. Two entries are path-scoped: github.com/anthropics and vercel.com/docs.

Anthropic
  platform.claude.com
  code.claude.com
  modelcontextprotocol.io
  github.com/anthropics
  agentskills.io

Programming languages
  docs.python.org
  en.cppreference.com
  docs.oracle.com
  learn.microsoft.com
  developer.mozilla.org
  go.dev
  pkg.go.dev
  www.php.net
  docs.swift.org
  kotlinlang.org
  ruby-doc.org
  doc.rust-lang.org
  www.typescriptlang.org

Web and JavaScript
  react.dev
  angular.io
  vuejs.org
  nextjs.org
  expressjs.com
  nodejs.org
  bun.sh
  jquery.com
  getbootstrap.com
  tailwindcss.com
  d3js.org
  threejs.org
  redux.js.org
  webpack.js.org
  jestjs.io
  reactrouter.com

Python frameworks and libraries
  docs.djangoproject.com
  flask.palletsprojects.com
  fastapi.tiangolo.com
  pandas.pydata.org
  numpy.org
  www.tensorflow.org
  pytorch.org
  scikit-learn.org
  matplotlib.org
  requests.readthedocs.io
  jupyter.org

PHP
  laravel.com
  symfony.com
  wordpress.org

Java
  docs.spring.io
  hibernate.org
  tomcat.apache.org
  gradle.org
  maven.apache.org

.NET and C#
  asp.net
  dotnet.microsoft.com
  nuget.org
  blazor.net

Mobile
  reactnative.dev
  docs.flutter.dev
  developer.apple.com
  developer.android.com

Data science and machine learning
  keras.io
  spark.apache.org
  huggingface.co
  www.kaggle.com

Databases
  www.mongodb.com
  redis.io
  www.postgresql.org
  dev.mysql.com
  www.sqlite.org
  graphql.org
  prisma.io

Cloud and DevOps
  docs.aws.amazon.com
  cloud.google.com
  learn.microsoft.com
  kubernetes.io
  www.docker.com
  www.terraform.io
  www.ansible.com
  vercel.com/docs
  docs.netlify.com
  devcenter.heroku.com

Testing and monitoring
  cypress.io
  selenium.dev

Game development
  docs.unity.com
  docs.unrealengine.com

Other tools
  git-scm.com
  nginx.org
  httpd.apache.org

Notably, pypi.org is not in this version of the list. Python's official documentation is preapproved; the Python Package Index is not.

A page has to work in search and in WebFetch

Publishing a page does not mean Claude reads it. The page must appear in WebSearch, be selected, allow WebFetch, and yield the requested fact after Haiku's extraction. A failure at any step keeps that fact out of the main conversation.

Write titles and descriptions for URL selection

WebSearch can give Claude enough information to answer a simple question, but it returns discovery metadata and synthesized findings rather than the raw page. Clear titles, direct descriptions, and crawlable public pages help a search model decide which URL deserves a closer look.

Put the important answer near the top

WebFetch truncates long converted pages before the extraction pass. Documentation pages should lead with the current version, exact install command, important constraints, and the canonical next step.

Return Markdown when you can

The Accept header gives publishers a chance to skip HTML cleanup. For a preapproved site, a small text/markdown response can reach the main model without Haiku at all. For other sites, clean Markdown still gives the extraction model a less noisy input. See How and Why You Should Serve Markdown Pages to Agents for an implementation pattern.

Count search and fetch separately

Search inclusion does not necessarily create a request in your server logs. WebFetch does. If you are measuring Claude Code traffic, look for Claude-User requests and keep them separate from search impressions, citations, and generic command-line traffic.

Claude usually sees a transformed version of the page

Claude Code's web access is a relay between models and tools, not a browser tab attached to one model.

WebSearch asks an Anthropic-hosted search turn to discover sources and write findings, then places that report into the main conversation. WebFetch retrieves one URL through the harness, converts it to Markdown, and usually asks Haiku to extract an answer before the main model sees anything.

The content in the final conversation may therefore be two transformations away from the original page. A WebSearch result proves that a URL was returned. A WebFetch request proves that the page was retrieved. Neither alone proves that the main model received the exact source text.

Sources