v1.6.1

fetch_page Filtering and Cache

Last updated


How the old and new fetch_page handle long pages, page relevance and the cache, and how a cached page is filtered again for each task.

How the two versions work


OldNew
Stored in cacheResult after noise removal and truncationOriginal content with only noise (ads, navigation and the like) removed
Long pagesCut at 100 KiBFiltered block by block against the task; only related blocks are returned
Page relevanceWhole page judged from its opening only; markdown onlyShort pages judged as a whole; long pages judged block by block and excluded only when no block is related; same rules for markdown and json
Over 1 MiBCut at 100 KiBThe first 1 MiB is checked and only blocks that directly answer the task are kept; if none, the agent is told the page is too large and to download it
Error pagesDetected by titleDetected by the actual HTTP status and the title

In the new version, task-based filtering runs right before returning, so freshly fetched content and content read from the cache go through the same path. The same page fetched for different tasks is filtered separately for each.

Cache and re-filtering


The new version separates what is stored from what is returned:
  1. The cache stores the original content: after fetching, the decision model removes only noise such as ads and navigation (markdown, keep_links off, content up to 1 MiB), and the rest is stored in ToriiDB as is. The cache never holds task-filtered results or withheld notices.
  2. No cache entry: the page is fetched and stored as in point 1, then filtered from that original content against the current task by the decision model and returned.
  3. Cache hit: when the same URL (same parameters) is requested again, the original content is read from the cache and filtered again against the current task by the decision model before returning.

So when different tasks request the same URL, none of them reuses the previous task's filtering. A page withheld as unrelated for one task is still available to the next related task.
Measured on English Wikipedia: Taiwan, two tasks in a row in one session:
FormatTaskSourceResultTime
markdownhow to bake sourdough breadfetchwithheld, 166 B7.6 s
markdowncapital of Taiwancachefiltered to 45 KB, includes Taipei0.7 s
jsonhow to bake sourdough breadfetchwithheld, 160 B7.2 s
jsoncapital of Taiwancachefiltered to 113 KB, includes Taipei, valid JSON1.4 s

After both calls the cache still holds the full original page (markdown 229 KB, json 572 KB). Reading from the cache saves the fetch; the remaining time is the task-based re-filtering.