Brave web-search tool with per-message globe toggle
nwhitehouse added a `web_search` tool backed by the Brave Search API. It's a binary toggle per message, hard-gated so the tool never appears in the schema when the user hasn't enabled it.
backend/src/lib/webSearch.ts (77 LOC, new) wraps the Brave Search API with a 12s AbortController timeout and returns results in the same shape as legalSearch - { title, url, snippet, source: "Web" }. That shared shape means the existing reference card component from feat-004 renders web results without any new code.
The tool is conditionally appended to the active schema via a WEB_TOOLS array, the same pattern used for LEGAL_TOOLS. When sources.web is false or absent, web_search isn't in the schema at all; the model can't call it. A system-prompt line is appended when web is enabled, steering the model toward it for current events and commentary. The frontend adds a globe icon button between the model toggle and send, blue when active, gray when off, resetting after submit.
When BRAVE_SEARCH_API_KEY is unset, the tool is still visible in the UI but returns zero results with a logged warning. Graceful degradation, no hard failure.
Brave's free tier is 2,000 queries per month. The same pattern would swap in any search API with minimal changes to webSearch.ts.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?