A plugin in front of Anthropic's or OpenAI's own API (a CPA or sub2api
relay whose quota the plugin reads) had no way to say its upstream runs
the hosted web search tool: searchesItself returned at once for any
signed-in account, letting only Codex and Grok through, so Claude Code's
WebSearch and Codex's web_search always went through magpie's own search.
Now a plugin's config hook can set `searches: true` on its provider, as
it sets `decide` (#1514). The host passes it through
(plugin.Provider.Searches), pluginProvider sets the provider's Searches,
and searchesItself honours it for a plugin's provider only, on Anthropic
or Responses and only where the plugin has a model on that API, the same
rule a custom provider's "Searches the web by itself" has (#359). Another
sign-in's Searches is never read; Codex and Grok are unchanged. As with a
relay, searchRank leaves it out, so magpie never picks it to search for
other models; Settings can name it by hand.
Documented in docs/subsystems/provider-plugins.md and the plugin guide
(site/public/docs plugins.html, en/zh/ja).
Verified:
- TestPluginSaidToSearch (new, gateway, through the real fake plugin on
bun and New().Handler()): with FAKE_SEARCHES the plugin's upstream gets
web_search_20250305; without it, it gets no search tool; Chat doesn't
search and searchRank is -1 either way.
- Broken by hand, each red: search.go reverted, plugins.go reverted,
host.js reverted (each "searches by itself on Anthropic: false"); with
the searchesItself assertion disabled and search.go reverted, the wire
check fails "said to search true, the plugin was sent []".
- TestMovedGrokSearchesItself, TestGrokPluginSearchesItself,
TestWebSearch* pass.
- go test -tags nogui ./internal/plugin ./internal/provider ok, and
./internal/gateway (see the run noted on #2027) under a sandbox HOME
with pinned caches; gofmt -l clean; GOOS=linux and GOOS=windows
go vet -tags nogui on the three packages clean.
- Not tried with a real CPA/sub2api plugin.