search: searcher request is non-streaming, so stream-only upstreams lose web_search_tool_result; add per-agent searcher
Summary
searchWith asks the searcher with stream: false (searchBody in internal/gateway/search.go). Some Anthropic-compatible upstreams only include server_tool_use / web_search_tool_result blocks when the request is streamed; their non-stream response contains only thinking / text, while usage.server_tool_use.web_search_requests still reports the searches. In that case the searcher did search, but searchWith parses zero pages: found is empty, Sources: is not appended, and the client's WebSearch result has no links (Claude Code shows No links found). The answer text still contains URLs, so it is not a total failure, but structured links are lost.
Reproduction
-
magpie 0.1.5456, macOS.
-
A custom provider with an Anthropic-compatible
/v1/messagesendpoint. The provider is markedsearches: trueand one of its models runs the hostedweb_search_20250305tool. -
Settings:
searchAll: true,searcher: <provider>/<model>, no search API configured. -
A client WebSearch (Claude Code) triggers the searcher. The searcher request magpie sends is
stream: false. -
Same query and model, directly:
- non-stream response
content[].type:["thinking", "text"] - stream response
content_block_starttypes:["thinking", "server_tool_use", "web_search_tool_result", "text"] - the stream's
web_search_tool_resultcontains the pages; the non-stream one has none. usage.server_tool_use.web_search_requestsis non-zero in both.
- non-stream response
-
Result:
searchWithreturns the text (it contains://, so it passes the empty check),foundis empty, noSources:list is appended, and the client receives text without structured links.
Proposal
-
Stream the searcher request. Send
searchBodywithstream: trueand reuse the gateway's existing SSE parsing to collectweb_search_tool_resultblocks. If streaming every searcher is undesirable, retry once withstream: truewhenfoundis empty (optionally only whenusage.server_tool_use.web_search_requests > 0, so a model that really did not search is not asked twice). -
Optional per-provider/model switch. Add a setting such as
searcherStream(auto/on/off) if some upstreams behave differently.autowould do the retry above;onwould always stream;offkeeps today's behavior. -
Per-agent scoping.
searchAllandsearcherare global settings. It would help to allow per-agent overrides (for exampleagents.<agent>.searcherandagents.<agent>.searchAll), so one agent can use a specific searcher while other agents keep their provider's own search. This is adjacent to #2286 (let an agent choose the search source) and #7708 (per-agent provider isolation). -
Expose
searchAllin the CLI.magpie settings listdoes not includesearchAll(it is only in the settings JSON), so scripted configuration has to edit the file directly. Listing it would make this usable frommagpie settings.
Workaround
A local SearXNG-compatible search API that streams the same upstream model and returns results works today (magpie search add searxng url=... + searchFirst=api), but it duplicates the searcher path and is not per-agent either.
Notes
No keys, internal hostnames or customer data are included. The provider is a generic self-hosted Anthropic-compatible endpoint.
Fixed in v0.1.5470 (db54f0bc74): magpie's web search now asks the searcher's model with stream: true and gathers the stream into the reply it reads. A relay that writes server_tool_use / web_search_tool_result only into a stream keeps its pages, so Claude Code's WebSearch gets its links and "Sources:" again. A relay that turns stream: false away, or answers it with an empty 200, now searches too. Only magpie's own search asks change; every other Messages request is sent as the client sent it.
Tested with a fake relay built from this report (whole request: thinking and text only, with web_search_requests: 1; streamed: the search blocks). All three cases were red on the old code and pass now. It wasn't tried against your relay itself, so please say if v0.1.5470 still shows "No links found".
Still open on this issue:
- a searcher, and Search with every model, chosen per agent (today both are one setting for every agent, in Settings › Models › Web search);
searchAllinmagpie settings list.
magpie's other whole asks on Messages (advisor, review, memory) and image drawing on a chat model have the same gap with a relay that only streams. They don't lose search results, but they fail; filed as #8775.
Confirmed on v0.1.5470 (macOS): WebSearch now returns structured links again — the searcher's web_search_tool_result pages come through, and no more "No links found". Tested against a custom Anthropic-compatible relay. Thanks for the quick fix. Per-agent searcher/searchAll remains the open ask.