openclaw - ✅(Solved) Fix Feature Request: Add Anthropic native web search (web_search_20260209) as a search provider [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#49949Fetched 2026-04-08 01:00:54
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
referenced ×7cross-referenced ×2

Add support for Anthropic's native web search tool (web_search_20260209 / web_search_20250305) as a search provider option alongside the existing Brave, Gemini, Grok, Kimi, and Perplexity providers.

Root Cause

The native Anthropic web search has significant advantages:

  1. Server-side execution — no external API key needed (uses your Anthropic API key)
  2. Built-in citationscited_text fields don't count toward token usage
  3. Domain filteringallowed_domains / blocked_domains at request level
  4. User location — localized search results via user_location parameter
  5. Dynamic filtering (v2, web_search_20260209) — Claude writes code to post-process results before loading into context, reducing token consumption
  6. Prompt caching — search results are cacheable across multi-turn conversations
  7. max_uses — built-in rate limiting per request
  8. Encrypted content — secure multi-turn conversation support

Fix Action

Fix / Workaround

Current Workaround

PR fix notes

PR #49954: feat: add Anthropic native web search provider (web_search_20260209)

Description (problem / solution / changelog)

Summary

Adds Anthropic's native web search as a new web search provider for OpenClaw, enabling users to leverage Claude's built-in web_search_20250305 / web_search_20260209 server-side tool.

Closes #49949

Architecture Note

All existing web search providers (Brave, Gemini, Perplexity, etc.) are client-side — OpenClaw intercepts web_search tool calls and routes them to external search APIs. Anthropic's web search is fundamentally different: it's a server-side tool that gets passed in the tools array of the Messages API, and Claude executes searches autonomously.

This PR bridges the gap pragmatically: the provider makes a direct call to the Anthropic Messages API with the web_search tool enabled, extracts the search results and citations from the response, and returns them in OpenClaw's standard format. This works within the existing architecture while leveraging Anthropic's native search.

Future optimization: A more native integration could detect when the active model is Anthropic and inject web_search_20260209 directly into the tools array, bypassing client-side interception entirely. This would be more token-efficient and support streaming search results.

Changes

  • extensions/anthropic/anthropic-web-search-provider.ts — New provider implementation
  • extensions/anthropic/index.ts — Register the web search provider
  • extensions/anthropic/openclaw.plugin.json — Declare web search provider + config schema
  • src/plugins/bundled-web-search.ts — Add anthropic to bundled provider list

Configuration

{
  "tools": {
    "web": {
      "search": {
        "provider": "anthropic",
        "anthropic": {
          "toolVersion": "web_search_20260209",
          "maxUses": 5,
          "allowedDomains": [],
          "blockedDomains": [],
          "userLocation": {
            "type": "approximate",
            "city": "San Francisco",
            "region": "California",
            "country": "US",
            "timezone": "America/Los_Angeles"
          }
        }
      }
    }
  }
}

API key reuses existing Anthropic auth (ANTHROPIC_API_KEY env var or configured profile).

Changed files

  • extensions/anthropic/anthropic-web-search-provider.ts (added, +401/-0)
  • extensions/anthropic/index.ts (modified, +2/-0)
  • extensions/anthropic/openclaw.plugin.json (modified, +14/-1)
  • src/plugins/bundled-web-search.ts (modified, +1/-0)

PR #50692: feat: add Anthropic native web search provider (#49949)

Description (problem / solution / changelog)

Summary

Adds "anthropic" as a new web search provider option, enabling Anthropic's server-side web_search_20260209 tool to be injected directly into the Messages API request. Claude handles search execution server-side with built-in citations, domain filtering, and prompt caching.

Closes #49949

What changed

New files

  • extensions/anthropic/src/anthropic-web-search-provider.ts — Provider plugin implementing the WebSearchProviderPlugin interface. Resolves config (tool version, allowed/blocked domains, max uses, user location) and builds the raw Anthropic server tool definition.
  • extensions/anthropic/src/anthropic-native-search-wrapper.ts — Stream wrapper that intercepts the onPayload callback to inject the server tool into the tools array for anthropic-messages API calls. Skips injection if a web_search server tool is already present.

Modified files

  • extensions/anthropic/index.ts — Registers the new web search provider.
  • src/plugins/bundled-web-search.ts — Adds "anthropic" to the bundled web search plugin ID list.

Tests (18 passing)

  • anthropic-web-search.test.ts (15 tests) — Config resolution, tool version validation, server tool building (domains, max_uses, user_location, edge cases).
  • anthropic-native-search-wrapper.test.ts (3 tests) — Injection into anthropic payloads, dedup when already present, passthrough for non-anthropic APIs.

Configuration

{
  tools: {
    web: {
      search: {
        provider: "anthropic",
        anthropic: {
          toolVersion: "web_search_20260209",  // or "web_search_20250305"
          allowedDomains: ["example.com"],
          blockedDomains: ["untrusted.com"],
          maxUses: 5,
          userLocation: {
            type: "approximate",
            city: "Denver",
            region: "Colorado",
            country: "US",
            timezone: "America/Denver"
          }
        }
      }
    }
  }
}

How it works

Unlike other providers that intercept web_search tool calls and route them to external APIs, this provider uses Anthropic's server tool mechanism. The stream wrapper patches the API payload to include the web_search_20260209 tool, and Claude executes searches server-side. Results come back as server_tool_use / web_search_tool_result content blocks with encrypted content and built-in citations.

No separate API key needed — uses the existing Anthropic API key.

Changed files

  • extensions/anthropic/index.ts (modified, +8/-0)
  • extensions/anthropic/src/anthropic-native-search-wrapper.test.ts (added, +54/-0)
  • extensions/anthropic/src/anthropic-native-search-wrapper.ts (added, +58/-0)
  • extensions/anthropic/src/anthropic-web-search-provider.ts (added, +175/-0)
  • extensions/anthropic/src/anthropic-web-search.test.ts (added, +122/-0)
  • openclaw-2026-03-18.log (added, +130/-0)
  • openclaw-2026-03-25.log (added, +3/-0)
  • src/bundled-web-search-registry.ts (modified, +7/-0)

Code Example

{
  tools: {
    web: {
      search: {
        provider: "anthropic",
        anthropic: {
          // Tool version (default: "web_search_20260209")
          toolVersion: "web_search_20260209",
          // Optional domain restrictions
          allowedDomains: ["example.com"],
          blockedDomains: ["untrusted.com"],
          // Optional user location for localized results
          userLocation: {
            type: "approximate",
            city: "Melbourne",
            region: "Victoria",
            country: "AU",
            timezone: "Australia/Melbourne"
          },
          // Optional max searches per request
          maxUses: 5
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Feature Request

Summary

Add support for Anthropic's native web search tool (web_search_20260209 / web_search_20250305) as a search provider option alongside the existing Brave, Gemini, Grok, Kimi, and Perplexity providers.

Background

Anthropic now offers a built-in web search tool that runs server-side as part of the Messages API. Unlike the current OpenClaw approach (where the gateway intercepts web_search calls and routes them to external providers), Anthropic's native tool is a server tool — Claude executes searches itself, and results include encrypted content with built-in citations.

Why This Matters

The native Anthropic web search has significant advantages:

  1. Server-side execution — no external API key needed (uses your Anthropic API key)
  2. Built-in citationscited_text fields don't count toward token usage
  3. Domain filteringallowed_domains / blocked_domains at request level
  4. User location — localized search results via user_location parameter
  5. Dynamic filtering (v2, web_search_20260209) — Claude writes code to post-process results before loading into context, reducing token consumption
  6. Prompt caching — search results are cacheable across multi-turn conversations
  7. max_uses — built-in rate limiting per request
  8. Encrypted content — secure multi-turn conversation support

Proposed Implementation

Add "anthropic" as a new provider option in tools.web.search.provider:

{
  tools: {
    web: {
      search: {
        provider: "anthropic",
        anthropic: {
          // Tool version (default: "web_search_20260209")
          toolVersion: "web_search_20260209",
          // Optional domain restrictions
          allowedDomains: ["example.com"],
          blockedDomains: ["untrusted.com"],
          // Optional user location for localized results
          userLocation: {
            type: "approximate",
            city: "Melbourne",
            region: "Victoria",
            country: "AU",
            timezone: "Australia/Melbourne"
          },
          // Optional max searches per request
          maxUses: 5
        }
      }
    }
  }
}

When provider: "anthropic" is selected, instead of intercepting the web_search tool call and routing it externally, the gateway should pass web_search_20260209 (or web_search_20250305) as a tool type directly in the Anthropic API request, letting Claude handle search execution server-side.

Pricing Context

  • Anthropic native search: $10 per 1,000 searches + standard token costs
  • This is comparable to other providers but with the advantage of tighter API integration

References

  • Anthropic Web Search Docs
  • Tool versions: web_search_20250305 (basic), web_search_20260209 (with dynamic filtering)
  • Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5, Opus 4.1, Opus 4, Sonnet 4, Haiku 4.5

Current Workaround

Using Gemini (Google Search grounding) as the search provider, which works well but lacks the tight integration, domain filtering, prompt caching, and citation features of the native Anthropic tool.

extent analysis

Fix Plan

To add support for Anthropic's native web search tool, follow these steps:

  • Update the tools.web.search.provider configuration to include "anthropic" as a new provider option.
  • Modify the gateway to pass web_search_20260209 (or web_search_20250305) as a tool type directly in the Anthropic API request when provider: "anthropic" is selected.

Example code snippet:

if provider == "anthropic":
    tool_type = "web_search_20260209"  # or "web_search_20250305"
    anthropic_config = {
        "toolVersion": tool_version,
        "allowedDomains": allowed_domains,
        "blockedDomains": blocked_domains,
        "userLocation": user_location,
        "maxUses": max_uses
    }
    # Pass tool_type and anthropic_config in the Anthropic API request
    response = anthropic_api_request(tool_type, anthropic_config)
  • Handle the Anthropic API response and return the search results.

Verification

To verify that the fix worked:

  • Test the search functionality with the "anthropic" provider option.
  • Check that the search results include encrypted content with built-in citations.
  • Verify that domain filtering, user location, and dynamic filtering are working as expected.

Extra Tips

  • Make sure to handle errors and exceptions properly when working with the Anthropic API.
  • Consider adding logging and monitoring to track search usage and performance.
  • Review the Anthropic Web Search Docs for the most up-to-date information on tool versions and supported models.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Feature Request: Add Anthropic native web search (web_search_20260209) as a search provider [2 pull requests, 1 participants]