← Back to PRs

#11444: Add extensible search providers for web_search

by dhc02 open 2026-02-07 20:21 View on GitHub →
gateway agents
## Summary Makes web_search providers extensible via the plugin system, allowing custom search providers (Kagi, SerpAPI, Tavily, etc.) without modifying core code. Closes #11399 ## Changes - **New provider registry** (`src/agents/tools/search-providers.ts`) - global registry for search providers - **Refactored web-search.ts** - uses registry instead of hardcoded switch statement - **New plugin type** (`SearchProviderPlugin`) - plugins can now register custom search providers - **Updated schema** - provider field accepts any string (validated at runtime against registered providers) - **Example plugin** (`extensions/kagi-search/`) - demonstrates how to build a custom provider ## Plugin API ```typescript import type { SearchProviderPlugin } from 'clawdbot'; const plugin: SearchProviderPlugin = { name: 'kagi-search', type: 'search-provider', providerName: 'kagi', async search(query, options) { // Implementation return { results: [...], provider: 'kagi' }; } }; export default plugin; ``` ## Backward Compatibility - Built-in providers (brave, perplexity) work exactly as before - Existing configs with `provider: brave` or `provider: perplexity` unchanged - No breaking changes ## Testing All 12 existing web-search tests pass locally. **Note:** 3 tests in `web-tools.enabled-defaults.test.ts` fail on this PR, but they also fail on `main` — these are pre-existing test issues (caching/isolation bugs), not regressions from this PR. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR makes `web_search` provider-extensible by introducing a global search-provider registry and wiring the tool to dispatch searches through registered providers (built-in Brave/Perplexity plus plugin-registered providers). It also loosens the config schema so `tools.web.search.provider` can be any string and adds an example Kagi provider plugin. Main issues to address before merge: - Provider plugins don’t reliably receive their per-plugin `plugins.entries.<pluginId>.config` because `web-search.ts` indexes config by provider id, not plugin id. - When falling back from an unknown provider to Brave, error payloads can incorrectly report the configured provider name instead of the effective provider used. Otherwise the architecture fits the existing plugin registry/runtime patterns (new `registerSearchProvider` API and registry bookkeeping), and built-in providers are moved behind the same interface. <h3>Confidence Score: 3/5</h3> - This PR is close to mergeable but has two correctness issues affecting plugin provider config and error reporting. - Core refactor to a provider registry is coherent and built-in providers remain functional, but provider plugins currently won’t receive their per-plugin config due to an ID mismatch, and fallback-to-Brave can emit misleading error payloads when the effective provider differs from the configured name. - src/agents/tools/web-search.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs