Repository navigation
Description
Problem
The engine/ module ships the web-search port — tool.SearchProvider, tool.SearchQuery, tool.SearchResult, and the sentinels ErrSearchUnavailable / ErrSearchBackendDown (engine/tool/search.go) — but no WebSearch tool body and no concrete SearchProvider. Both live in the root module's internal/, which is not importable.
So an external consumer that embeds engine/agent gets the interface and nothing that satisfies it. To have working web search they must reimplement both halves from scratch:
- The tool body — and with it the correctness- and safety-critical logic that surrounds the search call: fencing untrusted results (LLM01 / prompt injection), the
ErrSearchUnavailable(operator-disabled) vsErrSearchBackendDown(backend failed) degradation mapped to honest model-facing messages rather than a silent empty result or a hang, and the result-limit clamping the tool is the documented choke point for. - A provider — re-deriving the HTTP glue, auth, and response mapping for Exa / a generic HTTP backend / SearXNG that mecatl has already written and hardened.
Two copies of all of that, drifting apart, is exactly the failure mode #269 eliminated for the filesystem tools.
What I want
Out-of-the-box, importable web search: the WebSearch tool body and ready-to-use SearchProvider implementations I can plug in without reinventing them. Concretely, graduate into engine/adapter (in the spirit of #269, under the atrium-convergence theme "so engine importers don't reimplement them"):
- The
WebSearchtool.Toolbody — constructed over an injectedtool.SearchProvider, carrying the fencing, sentinel handling, and limit-clamping so consumers get the invariant-heavy behavior by import. - The concrete provider adapters mecatl already has — the Exa, generic HTTP, and SearXNG backends — as importable
engine/adapter/searchimplementations of the port, alongside the existing offline fake. A consumer should be able to pick a real backend and wire a key/URL, not write another HTTP client.
The port is already public; the point of a port is to make the implementations behind it reusable. Publishing only the interface, with both the tool and every real provider locked in internal/, advertises reuse while preventing it — and pushes the security-sensitive parts (fencing, degradation) and the tedious parts (per-backend HTTP) onto every consumer to redo.
Precedent
#269 graduated the six FS tool bodies into engine/adapter/tools for exactly this reason, and engine/adapter/* already advertises itself as offline test doubles and sane defaults for any engine consumer (mockllm, memfs, memstore, …). The WebSearch tool and its providers are the same role and belong in the same place.
Payoff
Engine importers get working web search out of the box — the hardened tool body and a choice of real backends — by importing them, instead of re-deriving and separately testing a second copy of code that must stay in lockstep with mecatl's.
Activity
feat(search): graduate WebSearch tool + providers into engine/adapter (…