Skip to content

Tokens to prove a claim

An agent that cites a page must check the quote. How many tokens does it read to do that? Part A of the eval counts them for 30 claims on 28 pages, in CI, with no model. Each claim has a question and an exact quote from a page. The pages are RFCs, Wikipedia articles, MDN, the documentation of Node.js and Python, government pages and one W3C recommendation.

The polite-crawler path is four calls of its MCP server. crawl_fetch stores the page, and crawl_find searches the store with the question. crawl_read reads 2,000 characters at the quote, and crawl_verify checks the quote. The other path reads the whole page as Markdown, the way WebFetch converts a page.

  • 30 of 30 claims are verified. crawl_verify found each quote.
  • In total, the pages as Markdown have 8.91 times the tokens of the polite-crawler path: 988,312 against 110,874.
  • For one claim, the median ratio is 2.22. A typical page is not long, so the difference for one claim is smaller than the difference in total.
  • On 4 very short pages, polite-crawler costs more. Its search results and its read window are longer than the page.
Tokens to prove each claim, the shortest page first on a log axis. The grid lines are at 1, 2 and 5 of each power of 10.
  • polite-crawler: fetch, find, read and verify
  • WebFetch proxy: the page as Markdown
  • The visible text of the page
  • polite-crawler costs more (4 claims)

RFC 9110: Why can HTTP not use the 418 status code?

polite-crawler reads 2,848 tokens to prove the claim. The page as Markdown has 161,837 tokens, and its visible text 106,510. polite-crawler reads 57 times fewer.

  • crawl_fetch265
  • crawl_find2,270
  • crawl_read0
  • crawl_verify313

crawl_find gives the page at place 4 of its results. The quote is past the cut of the reader (50,000 characters), so the path has no read. The excerpt of crawl_verify shows the text around the quote.

The axis is a log axis. The pages go from 701 to 161,837 tokens, and a linear axis puts the short pages at 0. On a log axis, the same distance is the same ratio. The panel below the figure shows the four steps of the polite-crawler path on a linear bar. A stack of parts on a log axis gives the wrong lengths.

The cost of polite-crawler stays between 2,010 and 4,318 tokens for each claim. It reads search results and a window of the page, not the page. The cost of the page grows with the page. RFC 9110 as Markdown has approximately 56 times the tokens of the path. The Wikipedia article about the mathematician has approximately 49 times the tokens.

The tokens of a session that proves 1 to 30 claims on a log axis: each grid line is 10 times the last
  • polite-crawler, with the tool definitions (5,993 tokens) one time at the start
  • WebFetch proxy: each page as Markdown

In this order, polite-crawler stays below the proxy from claim 2 on. Before that, the one-time tool definitions weigh more than the pages. After 30 claims: 116,867 against 988,312 tokens.

Show the running totals as a table
ClaimsThe last pagepolite-crawlerWebFetch proxy
1RFC 93099,6087,935
2RFC 930913,15715,870
3RFC 211916,80616,931
4RFC 911019,696178,768
5RFC 911022,544340,605
6RFC 114926,151341,306
7RFC 232429,858346,670
8RFC 825933,573355,325
9RFC 658537,133360,145
10RFC 418040,820364,074
11RFC 844644,415454,824
12Wikipedia: Web crawler48,479482,091
13Wikipedia: Robots.txt52,506502,180
14Wikipedia: Alan Turing54,516601,352
15Wikipedia: Python (programming language)57,994670,578
16MDN: Array.map61,831678,739
17MDN: JSON.parse65,512684,256
18MDN: Promise.all69,227691,699
19Node.js: fs72,723812,935
20Node.js: path76,673820,950
21Node.js: events80,135847,687
22Python: json84,345857,521
23Python: functions88,510885,167
24Python: collections92,545901,260
25PEP 2096,342901,995
26Declaration of Independence100,510905,732
27US Constitution104,586914,263
28Data Protection Act 2018108,297920,101
29Human Rights Act 1998112,549925,201
30WCAG 2.1116,867988,312

The MCP server costs 5,993 tokens one time in each session: the definitions of its tools. Thus a session that proves one short claim costs more with polite-crawler. The order of the claims changes when polite-crawler goes below the proxy and stays there:

  • In the order of the eval, from claim 2 on.
  • With the short pages first, from claim 12 on.
  • With the long pages first, from claim 1 on.

After all 30 claims, the order does not matter: 116,867 tokens against 988,312. The figure counts no tool definition for WebFetch.

The tokens of each claim. The buttons in the header sort the table.
RFC 9309What is the smallest robots.txt parsing limit that a crawler can use?7,9355,6793,6152.201
RFC 9309How long can a crawler use a cached robots.txt file?7,9355,6793,5492.241
RFC 2119What does the key word MUST mean in an RFC?1,0619033,6490.29 (polite-crawler costs more)6
RFC 9110What does the 404 Not Found status code mean?161,837106,5102,89056.002past the cut: no read
RFC 9110Why can HTTP not use the 418 status code?161,837106,5102,84856.824past the cut: no read
RFC 1149What kind of service do avian carriers provide for IP datagrams?7016233,6070.19 (polite-crawler costs more)1
RFC 2324What happens when someone tries to brew coffee with a teapot?5,3644,3093,7071.451
RFC 8259Which character encoding must JSON text use between systems?8,6556,2953,7152.331
RFC 6585What does the HTTP status code 429 mean?4,8203,5573,5601.351
RFC 4180How are the records of a CSV file separated?3,9292,7853,6871.071
RFC 8446What is the primary goal of TLS 1.3?90,75068,1473,59525.242
Wikipedia: Web crawlerWhat is a web crawler?27,26711,3864,0646.711
Wikipedia: Robots.txtWhat is the file robots.txt for?20,0897,1014,0274.991
Wikipedia: Alan TuringWhen was Alan Turing born?99,17232,6672,01049.341
Wikipedia: Python (programming language)Which language did Python succeed?69,22622,6533,47819.902
MDN: Array.mapWhat does the map method of an array return?8,1613,1343,8372.134
MDN: JSON.parseWhat does JSON.parse do?5,5172,4823,6811.501
MDN: Promise.allWhat does Promise.all take as input?7,4433,3123,7152.001
Node.js: fsWhat is the Node.js fs module modeled on?121,23666,1293,49634.681
Node.js: pathWhat does the Node.js path module do?8,0154,7023,9502.032
Node.js: eventsWhich architecture is the Node.js core API built around?26,73716,8043,4627.721
Python: jsonWhat kind of format is JSON, according to the Python documentation?9,8346,3844,2102.341
Python: functionsAre the built-in functions of Python always available?27,64618,8064,1656.641
Python: collectionsWhat does the Python collections module implement?16,09310,8754,0353.994
PEP 20What is the first aphorism of the Zen of Python?7354343,7970.19 (polite-crawler costs more)2
Declaration of IndependenceWhich truths does the Declaration of Independence hold to be self-evident?3,7372,5764,1680.90 (polite-crawler costs more)1
US ConstitutionWhy did the people of the United States ordain the Constitution?8,5316,3704,0762.091
Data Protection Act 2018What does the UK Data Protection Act 2018 make provision about?5,8382,8023,7111.571
Human Rights Act 1998Does the UK Human Rights Act protect the right to life?5,1003,7884,2521.202
WCAG 2.1What does WCAG 2.1 cover?63,11128,8944,31814.621

The ratio is the tokens of the page as Markdown divided by the tokens of the polite-crawler path. A ratio below 1 is a claim on which polite-crawler costs more. The place in crawl_find is the place of the page of the claim in the results of the search for the question.

  1. The fetch. The eval fetched each URL one time into a new store, with the default identity of the crawler. The crawler obeyed robots.txt and the pace of each site, and it opened no browser.
  2. The archive. The run exported the store as a WACZ file. Its SHA-256 starts with 28f5d5cd32ea038f.
  3. The replay. The measurement read the WACZ file into a new store and sent no request. A second replay gave the same numbers.
  4. The count. For each claim, the count is all the text of the four tool results. The proxy is the HTML of the page as Markdown (turndown), with no script, style, noscript or template elements.

The README of the eval gives each step, the units and the checks. The numbers of this page are in eval-a.json.

  • The tokenizer is a proxy. The count uses the encoding {evalA.tokenizer} of the package gpt-tokenizer. It is not the tokenizer of Claude, and Claude gives different counts. The two paths use the same tokenizer, so a ratio depends less on the tokenizer than a count.
  • The real WebFetch is different. The WebFetch tool of Claude Code converts the page to Markdown and gives it to a small model with the prompt. The main model gets the answer of that model, not the page. That answer is not an exact quote that the main model can check. To check a quote, a model reads the text of the page. The proxy counts that text, with no limit of WebFetch.
  • The read window starts at the quote. crawl_verify gives the place of the quote, so the agent knows where to read. An agent that reads from the start of each page in ranges of 4,000 characters reads 202,067 tokens in total, not 110,874.
  • Some quotes are past the cut. The reader of polite-crawler cuts the text of a page at 50,000 characters. For 2 claims (RFC 9110), the quote is past the cut. Then the path has no read, and the excerpt of crawl_verify shows the text around the quote.
  • The count leaves out the text that the agent writes (the arguments of each call) and the system prompt.
  • Part B measured the real cost. In real sessions of Claude Code, WebFetch costs less than polite-crawler, because a small model reads the page. With polite-crawler-mcp 0.2.1, a session with WebFetch cost approximately half as much. With the shorter tool text of 0.2.3, it costs approximately 60%.