CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/API & SDK
API & SDK/2026-03-30Advanced

Building a Search-Augmented AI Assistant with Claude API: Web Search × Dynamic Filtering × Citations

Learn how to combine Claude API's Web Search Tool, Dynamic Filtering, and Citations API to build a production-grade search-augmented AI assistant that returns accurate, source-backed answers.

web-search4citationsdynamic-filteringproduction111api38code-execution3rag4

Premium Article

Why Search-Augmented AI Matters

As large language model (LLM) adoption scales up in production systems, information freshness and answer accuracy remain the two most critical challenges. In March 2026, Anthropic promoted the Web Search Tool and Programmatic Tool Calling to general availability (GA) and introduced Dynamic Filtering — a powerful feature that uses code execution to filter search results before they enter the context window.

This guide covers how to combine Web Search Tool, Dynamic Filtering, and Citations API to build a search-augmented AI assistant that returns accurate, source-backed answers in production. We'll walk through architecture design, complete code implementation, cost optimization strategies, and resilient error handling patterns.

While traditional RAG (Retrieval-Augmented Generation) requires maintaining your own vector database, the Web Search Tool lets you use the entire internet as your knowledge base. By layering Dynamic Filtering on top, you eliminate noise from search results, optimize token consumption, and achieve higher-quality answers.

For a broader take on search-augmented systems, see Building an Autonomous Research Agent with Claude API.

Architecture Overview — Integrating Three APIs

The search-augmented AI assistant architecture consists of three layers.

Search Layer (Web Search Tool): Executes real-time web searches based on user queries and collects relevant sources. The web_search_20260209 version supports domain filtering and user location settings.

Filtering Layer (Dynamic Filtering + Code Execution): Programmatically filters search results using a sandboxed code execution environment, removing irrelevant results before they consume context window tokens. This layer is the key to simultaneously improving both token efficiency and answer accuracy.

Answer Generation Layer (Citations API): Generates answers based on filtered information and automatically attaches source citations to each claim.

// Conceptual architecture code
import Anthropic from "@anthropic-ai/sdk";
 
const client = new Anthropic();
 
// Basic search-augmented assistant configuration
async function searchAugmentedAssistant(userQuery: string) {
  const response = await client.messages.create({
    model: "claude-sonnet-4-6",
    max_tokens: 8096,
    tools: [
      {
        type: "web_search_20260209",
        name: "web_search",
        // Dynamic Filtering: filter search results via code execution
        dynamic_filtering: { enabled: true },
        // Domain restrictions (optional)
        allowed_domains: ["docs.anthropic.com", "github.com"],
      },
    ],
    // Enable Citations
    citations: { enabled: true },
    messages: [
      {
        role: "user",
        content: userQuery,
      },
    ],
  });
 
  return response;
}

This design creates an end-to-end pipeline: user query → web search → dynamic filtering → cited answer generation.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A design that cuts input tokens 40–60% with Dynamic Filtering while improving answer accuracy
An implementation that scores overall reliability from citation density, unique sources, and trusted-domain ratio
A multi-layer fallback that degrades from filtered search to basic search to model-only knowledge
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-06-27
When Claude API Streaming Stops Without an Error: Detecting Silent Stalls and Resuming Mid-Stream
How to catch the 'silent stall' where Claude API streaming stops with no exception at all, using a content-level watchdog that times the gap between tokens, plus a resume path that carries received text forward as an assistant prefill, and a four-layer timeout budget for long-running automation.
API & SDK2026-06-25
When Your Support AI Is Confidently Wrong in Production — Notes on Refusing Outside Its Grounding and Routing to Humans
A field-tested approach to the Claude API support agent that demos perfectly yet states non-existent facts in production. Covers deciding 'don't answer' at retrieval time, grounded generation, measuring confident-wrong rate, and tuning escalation precision.
API & SDK2026-06-23
When Claude API Prompt Caching Quietly Stops Hitting in Production — Field Notes on TTL and Measured Savings
Prompt caching works beautifully the day you ship it, then quietly stops hitting in production. The five things that break the prefix, how to choose between 5-minute and 1-hour TTL, and how to measure real savings from usage instead of guessing.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →