# Agent search: Raj's free version against Cloudflare's "Search for Agents"

Tested 2026-11-27. The questions were run from 1:22 to 1:57pm Pacific (`results.json` `run_at`), on the same two pages (ai.withmagic.ai and its /south-bay/ page).

## The bottom line

- **Finding the right section:** Raj's version put the right section first on 21 of 25 real questions. Cloudflare's did on 18 of 25.
- **Saying "nothing here":** Cloudflare's was right on all 5 off-topic questions. Raj's was right on only 2 of 5. It answered "Do you sell car insurance?" with the "not in California" section, for example.
- **What the AI gets back:** Raj's version returns one section, about 380 characters. Cloudflare's returns a chunk of about 3,300 characters, which is half a page. So the AI assistant reading Cloudflare's answer has to dig the right part out of the chunk itself.
- **Speed:** Raj's version took 187 ms on a typical call and 4.8 s on the very first call (it loads a small model). Cloudflare's took 660 ms on a typical call and 855 ms on the first.
- **Cost:** Raj's version costs $0 and runs inside Netlify's free plan. Cloudflare includes 1,000 searches a month, then charges $0.75 per 1,000, with no spending cap. That billing starts December 1, 2026.
- **Setup:** Cloudflare is one switch, with no code and no build step, and it re-reads the site every day by itself. That is its real advantage. In this test, though, the switch alone never produced a working search address: it answered 503 on about 30 tries between 1:22 and 1:57pm Pacific.

## Words used here

- **Agent search:** a web address, `/.well-known/search?q=...`, that an AI assistant (an "agent") can ask questions. It answers with the matching parts of the site as plain text, instead of the agent having to read every page.
- **Section:** one heading on the page plus the text under it, for example "How it starts, and what it costs".
- **Chunk:** the piece of text Cloudflare stores and returns. Cloudflare cuts each page into pieces of about 1,024 tokens (a token is roughly three quarters of a word). Each of these two pages became 2 chunks.
- **Top-1 / top-3:** the right section was the first result, or one of the first three.
- **Cold / warm:** cold is the first call after the system has been idle. Warm is every call after that. The warm number here is the median, meaning the middle value.

## Results

The 30 questions and their right answers were written and committed (the questions commit, `questions.json`) before either system was asked anything.

| | Raj's version | Cloudflare |
|---|---|---|
| Right section first, 25 real questions | **21** | 18 |
| Right section in the first 3 | **23** | 18 |
| Page's own words (10) | 10 first | 9 first |
| Same meaning, different words (10) | 8 first | 6 first |
| Vague or multi-part (5) | 3 first | 3 first |
| Correct "no match" on 5 off-topic questions | 2 | **5** |
| Text returned in the first result | **~380 characters** | ~3,300 characters |
| First call (cold) | 4,811 ms | **855 ms** |
| Typical call (warm median) | **187 ms** | 660 ms |
| Slow calls (90th percentile) | **252 ms** | 990 ms |
| Cost per 1,000 searches | $0 inside Netlify Free | $0 for the first 1,000 a month, then $0.75 |

Where each one missed:
- **Raj's version** answered 3 off-topic questions instead of saying "no match": the Hermosa Beach weather, car insurance, and the World Series. It said "no match" for "is it safe", which should have found the data section. It also missed "Can I sign off on messages first?"
- **Cloudflare** returned nothing for 7 real questions, including "How much does a first build cost?", which uses the page's own words. The others were "What will it set me back?", "Do you meet face to face in Torrance?", "Has anyone actually used one of these, like a real shop?", "I am based in Texas, does that matter?", "I run a plumbing company...", and "is it safe". Cloudflare drops any result scoring below 0.4. That same cutoff is what made it right on every off-topic question.

## How the test was run

1. **Questions:** 30, written the way a small-business owner might ask an AI assistant. 10 use the page's own words, 10 say the same thing in other words, 5 are vague or ask two things, and 5 are off-topic. Each one names its right section, taken from the page headings, plus a short phrase from that section (`questions.json`).
2. **Scoring:** a result counts as right when its text contains that phrase. An off-topic question counts as right only when the system returns no results.
3. **Raj's version:** each question was sent once to the live `https://ai.withmagic.ai/.well-known/search?q=`, 0.7 seconds apart. The site's own rate limit of 20 calls a minute (set in `netlify.toml`, enforced by Netlify) blocked questions 25 to 30, so those 6 were sent again 3.5 seconds apart. The answers came back in "hybrid" mode (keyword plus meaning, header `X-Search-Mode: hybrid`).
4. **Cloudflare:** the test used a spare domain Raj owns, xspot.lol, which normally just redirects to another of his domains. A copy of the two pages was put on a new Netlify test site at xspot.lol, behind Cloudflare, with no search function of its own. Search for Agents was then switched on for that zone.
5. **Same computer for both:** Raj's desktop in Los Angeles, using Node.js to make the calls.

## Limits (read these before quoting the numbers)

- **Cloudflare's own search address never worked.** `xspot.lol/.well-known/search` answered "503 Search is being configured" every time it was tried: about 30 tries between 1:22 and 1:57pm Pacific (`results.json` `run_at`). The time of each try was not saved, so how long it stayed at 503 after the switch was turned on is not known exactly. (The endpoint note in `results.json`, written during the test, says "40 minutes"; the saved run window is about 35.) Cloudflare marks the feature as beta. The switch also did not create the search index (Cloudflare calls it an "AI Search instance") on its own. So the instance was created through Cloudflare's API with the settings the docs list: named `search-for-agents-<zone id>`, reads the whole domain by following links 5 deep, no subdomains. Cloudflare then read the two pages in 2 minutes 41 seconds. The questions went to that instance through Cloudflare's search API (`/ai-search/instances/<id>/search`). It is the same index and the same search engine that the `/.well-known` address uses, but the speed numbers were measured through `api.cloudflare.com`, not through the website's own address.
- **The chunk size flatters Cloudflare.** Each chunk is half a page, so a returned chunk "contains" the right section far more easily than a 380-character section does. On a bigger site, the gap in what the AI receives would matter more.
- **Search for Agents covers the whole domain, not one subdomain.** It reads `https://<domain>` and skips subdomains by default. That is why the test copy had to sit at xspot.lol itself, and why it was never switched on for withmagic.ai, which serves live sites.
- **The sample is small.** It is 30 questions on 2 short pages, and each system was asked each question once.
- **One scoring phrase also appears in the page's opening section.** "unpaid invoices" is in the opening text as well as in "Get paid faster". This affected one result. Question 25 ("Can it answer leads and also handle billing, and how do we get started?") got "Where does my data go?" first from Raj's version, which is wrong. Its second result was the opening section ("More booked jobs. Fewer hours on paperwork."), which was scored right only because it contains "unpaid invoices". Without that, the first right section would have been the third result, "How it starts, and what it costs". So the question counts as wrong for top-1 either way and right for top-3 either way.

## Setup, side by side

**Raj's version** (code in `outcomes-site`, README section "Agent search")
- It was built in one AI-assisted session on 2026-11-27. The first commit was at 11:30am and meaning search was added at 1:01pm.
- The parts are: a build script that turns the pages into a search index, a Netlify Function that answers the search, and a free model (all-MiniLM-L6-v2, 23 MB) that runs inside the function.
- **Ongoing work:** the index has to be rebuilt before every deploy (`tools/build-search-index.mjs`). Netlify blocks the QUERY method, so only GET and POST work.
- **Limits:** my rate limit in `netlify.toml` allows 20 calls a minute per visitor, and a Cloudflare rule blocks more than 20 calls in 10 seconds per visitor.

**Cloudflare Search for Agents**
- It is one switch in the dashboard, or the zone setting `search_for_agents` set to `on` through the API.
- **Ongoing work:** none. There is no build step, and Cloudflare re-reads the site every 24 hours (`sync_interval` 86400).
- **Defaults, read back from the instance:** keyword plus meaning search, the model `@cf/qwen/qwen3-embedding-0.6b`, chunks of 1,024 tokens, results below a score of 0.4 dropped, and answer caching on.
- **In this test:** it needed the manual instance step described under Limits, and the public address still did not come up.

## Costs, with sources

- **Cloudflare AI Search** ([limits and pricing page](https://developers.cloudflare.com/ai-search/platform/limits-pricing/), read 2026-11-27):
  - Included each month: 1,000 semantic (meaning) searches, 1,000 full-text searches, 5 million tokens of page reading, and 10 GB-month of storage.
  - After that: $0.75 per 1,000 semantic or hybrid searches, $0.10 per 1,000 full-text searches, and $0.75 per million tokens of page reading.
  - That page lists no spending cap, and billing starts December 1, 2026.
  - Search for Agents is billed at these AI Search prices ([Cloudflare blog](https://blog.cloudflare.com/search-for-agents)).
  - Raj's Cloudflare account is on the paid Workers plan, so any searches past the included amount would be billed, not blocked.
- **Raj's version:**
  - It costs $0 a search. Netlify's Free plan includes 125,000 function calls a month (read from the Netlify API).
  - That limit is per site, not per team: Netlify's [legacy pricing table](https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-legacy-plans/legacy-pricing-plans/) says "125k invocations per site/month", and the Netlify API's usage answer for this site (`/sites/<id>/usage`) shows `included: 125000` for the site itself. (Corrected 2026-11-27: this line first said the 125,000 was shared by every site on the team. The 31,712 calls then quoted were the whole team's total, not this site's.)

## What Cloudflare does better, honestly

- **No code and no upkeep:** there is nothing to build and no index to rebuild, and it re-reads the site daily.
- **"No match":** it was right on all 5 off-topic questions. Raj's version was right on 2, which is the clearest fix to make next: a minimum score.
- **First call:** about 0.9 s against 4.8 s.
- **Any site:** it works on any site Cloudflare already serves, not only on Netlify.

## What Raj's version does better

- **Accuracy:** it put the right answer first more often (21 against 18 of 25) and missed fewer real questions (2 against 7).
- **Precision:** it returns the one section that answers the question, so the AI reads about 380 characters instead of about 3,300.
- **Speed after the first call:** a typical call was 187 ms against 660 ms.
- **Cost:** it has a fixed cost of $0, with no per-search bill and no exposure to an uncapped bill.
- **It worked on the day:** it was live and answering. Cloudflare's public address did not come up during the test.

## Cleanup (done 2026-11-27, about 1:58pm, each step checked afterward)

- **Search for Agents:** switched off on xspot.lol (`search_for_agents` = `off`). It was confirmed off on withmagic.ai too, where it was never switched on.
- **AI Search instance:** deleted. The account now lists 0 instances. An empty namespace named "default", created automatically, is still there. It holds nothing.
- **Netlify test site:** `agentsearch-test-xspot` deleted. The Netlify API now answers 404 for it.
- **DNS:** the test record `agentsearch-test.xspot.lol` was deleted, and the xspot.lol record was put back to `A 192.0.2.1`, proxied, as before.
- **Redirect:** the xspot.lol redirect rule was put back to `true`, which sends everything to his other domain, as before.
- **Rate limit:** the test rate-limit rule was removed.
- **Cloudflare usage during the test:** 2 pages read into 4 chunks (4 vectors), 31 searches, and about 30 calls to the `/.well-known` address that all got the 503 answer. Cloudflare's API shows no usage or bill total for AI Search. All of this happened before billing starts on December 1, 2026.

Files: `questions.json` (fixed first), `results.json` (every answer, status and time).

## After the fix (fix committed 2026-11-27 at 3:24pm PT as 2ce10b2 in the private site repo; the published re-runs ran at 4:49pm PT, `run_at` in rerun-after-fix.json)
Off-topic questions were the one place Cloudflare clearly won (5 of 5 against our 2 of 5). We added two "no match" rules: the question's average meaning score across the whole site must reach 0.12, and a question that shares no word with the site needs a best score of at least 0.36. The rules were picked using the 30 questions above, so we also ran 10 new questions, committed before they were run (qa/compare/holdout.json).

| | Before the fix (local run, output not saved or published) | After the fix |
|---|---|---|
| Off-topic, correct "No matches" (original 5) | 2 of 5 | 5 of 5 |
| Real questions, right section first (original 25, run locally) | 20 of 25 | 20 of 25 (published: `public/agent-search/data/rerun-after-fix.json`) |
| Holdout off-topic, correct "No matches" (4 new) | 2 of 4 | 3 of 4 ("Do you repair laptops and phones?" still matches the word "phone") |
| Holdout real questions, right first / in top 3 (6 new) | 5 of 6 / 6 of 6 | 5 of 6 / 6 of 6 (published: `public/agent-search/data/holdout-results.json`) |

Limit: if the meaning model fails to load, the search falls back to keywords only and these rules do not apply. Live check after deploy: "best pizza recipe" and "weather tomorrow" return "No matches"; "what will it set me back" still returns the price section.
