Optimize Agent Responses with Web Search Result Filtering
Streamline agent workflows by filtering out raw web search data.
Use the 'response_inclusion' parameter in Claude's web search tools to remove unnecessary data blocks and receive cleaner API responses.
The Scenario
You are building an AI agent that performs web searches and you want to reduce the token usage and 'noise' in the API response to make it easier for the agent to process the final answer.
Before & after
API responses for web searches previously included large blocks of raw source data alongside the answer, forcing developers to write custom code to strip out the junk. This cleanup took 15–20 minutes to implement.
By adding the 'response_inclusion' parameter, you receive only the synthesized answer, reducing the data your agent has to parse by up to 90%. This saves 2–3 minutes of post-processing.
The Prompt
// Example API call configuration for cleaner web search results
{
"tools": [{
"name": "web_search",
"parameters": {
"query": "[YOUR_SEARCH_QUERY]",
"response_inclusion": "minimal"
}
}]
}The updated web search and fetch tools (web_search_20260318) allow for a 'response_inclusion' parameter. This tells the API to drop the raw result blocks it used to generate the answer, providing a cleaner, more efficient response for agentic workflows.
Source
Claude Platform - Claude API Docs"adding a response_inclusion parameter to drop consumed result blocks from the API response for agentic workflows."
