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
| Old | New | |
|---|---|---|
| Stored in cache | Result after noise removal and truncation | Original content with only noise (ads, navigation and the like) removed |
| Long pages | Cut at 100 KiB | Filtered block by block against the task; only related blocks are returned |
| Page relevance | Whole page judged from its opening only; markdown only | Short 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 MiB | Cut at 100 KiB | The 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 pages | Detected by title | Detected 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:
- The cache stores the original content: after fetching, the decision model removes only noise such as ads and navigation (markdown,
keep_linksoff, content up to 1 MiB), and the rest is stored in ToriiDB as is. The cache never holds task-filtered results or withheld notices. - 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.
- 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:
| Format | Task | Source | Result | Time |
|---|---|---|---|---|
| markdown | how to bake sourdough bread | fetch | withheld, 166 B | 7.6 s |
| markdown | capital of Taiwan | cache | filtered to 45 KB, includes Taipei | 0.7 s |
| json | how to bake sourdough bread | fetch | withheld, 160 B | 7.2 s |
| json | capital of Taiwan | cache | filtered to 113 KB, includes Taipei, valid JSON | 1.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.