Claude's Web Search Tool: Dynamic Filtering and Built-In Citations
Source: Anthropic — Claude Developer Platform docs — verified 2026-07-10
Summary
Anthropic's server-side web_search tool (current version web_search_20260318) runs the entire search loop — querying, fetching, and citing — on Anthropic's infrastructure rather than the caller's. The newest versions add dynamic filtering, where Claude writes and executes code to filter search results before they ever reach its context window, and citations are automatic and always-on rather than an opt-in flag.
Key Takeaways
- Dynamic filtering runs web search from inside code execution: results are filtered server-side before hitting Claude's context, cutting token usage on search-heavy requests — no extra
code_executiontool declaration needed, it's provisioned automatically. - Citations require no opt-in for web search (unlike document citations, which need
citations: {enabled: true}). Every claim Claude draws from a search result can carry aweb_search_result_locationcitation withurl,title,cited_text(up to 150 characters), and anencrypted_indexthat must be echoed back on later turns. encrypted_contenton each search result must be passed back unmodified in multi-turn conversations — the API decrypts it server-side to restore the result into context; a missing or edited value is a hard 400.- A long-running search turn can return
stop_reason: "pause_turn"— the fix is to resend the paused assistant turn unchanged, not to append a new user message telling it to continue.
Discussion
(No questions yet — ask a follow-up in the chat box below, or via a Claude Code chat session on this repo; answers get appended here.)