Skip to content
IFAI

AI tools

Claude can now write code to filter its own web searches

Published Reach 42

Anthropic just added dynamic filtering to Claude's web search and fetch tools on the API. Instead of dumping raw HTML into context, Claude writes and runs code to strip junk data before reasoning over it, boosting benchmark accuracy by 11% while slashing input tokens by 24%. It is on by default for Sonnet 4.6 and Opus 4.6.

Claude can now write code to filter its own web searches
Image: claude.com

Most AI agents search the web like hoarders. They query a topic, dump entire megabytes of raw HTML, banner ads, and navigation menus straight into the context window, and then try to make sense of the mess.

That brute-force approach eats through tokens and frequently distracts the model. Now, Anthropic is giving Claude a scalpel.

Alongside the launch of Claude Sonnet 4.6 and Opus 4.6, Anthropic rolled out upgraded web search and web fetch tools featuring what it calls dynamic filtering. Instead of swallowing raw web pages whole, Claude can now natively write and execute code in real time to clean, filter, and extract relevant data before it ever hits the context window.

Coding before reading

Web browsing is traditionally one of the most token-hungry tasks an AI agent can perform. When agents ingest full HTML payloads, context bloat dilutes reasoning and invites hallucinations.

With dynamic filtering enabled, Claude intercepts search results and page fetches by spinning up Python scripts in an isolated sandbox. It parses the document, extracts key snippets, cross-references sources, and discards junk before passing the cleaned data to its core context.

Quora's multi-model platform Poe put the feature to work early. Gareth Jones, Poe's Product and Research Lead, noted that Opus 4.6 with dynamic filtering achieved top accuracy on their internal evals against rival frontier models. He described the agent as acting like an actual human researcher who writes quick scripts to slice through data rather than reading raw source code.

The benchmark gains are substantial. On BrowseComp, which tests an agent's ability to locate obscure, hard-to-find facts, dynamic filtering lifted Sonnet 4.6 from 33.3% to 46.6% accuracy, while Opus 4.6 jumped from 45.3% to 61.6%.

On DeepsearchQA, which demands comprehensive multi-step research with multiple valid answers, Sonnet's F1 score rose from 52.6% to 59.4%, and Opus climbed from 69.8% to 77.3%. Across both benchmarks, accuracy rose by an average of 11% while consuming 24% fewer input tokens.

Alongside the search update, Anthropic graduated several core agentic capabilities to general availability, including code execution, persistent cross-session memory, programmatic tool calling, tool search, and inline tool examples.

Why it matters

We think this is one of the smartest architectural shifts in agent design this year: treating the context window as premium workspace rather than a landfill.

For builders creating research agents or document retrieval pipelines, this directly translates to sharper answers and fewer context-drift hallucinations. If you are verifying citations, digging through technical API docs, or parsing financial disclosures, enabling the new endpoints is an easy win.

There is a cost catch worth noting. While Sonnet 4.6 saw an overall reduction in price-weighted token spend, Opus 4.6 actually became more expensive to run on these benchmarks. That is because code generation burns output tokens, and on a top-tier model, output tokens carry a steep premium. Production teams will need to measure their specific query patterns before leaving Opus on default search duty.

Zooming out, this moves the industry away from the myth of infinite context windows. Shoving millions of raw tokens into a prompt was always an inefficient crutch. By turning web browsing into an active programmatic data pipeline, Anthropic shows that the real future of AI agents lies in smarter preprocessing, not bigger context windows.

Sources (1)

  1. [1]
    claude.com(opens in a new tab)Originalclaude.com

Best of AI, daily