feat(tools): add Bocha web search provider#874
Open
shikihane wants to merge 2 commits intosipeed:mainfrom
Open
feat(tools): add Bocha web search provider#874shikihane wants to merge 2 commits intosipeed:mainfrom
shikihane wants to merge 2 commits intosipeed:mainfrom
Conversation
Add BochaSearchProvider implementing the SearchProvider interface, using the Bocha AI web search API (api.bochaai.com). Appended at the end of the provider priority chain (lowest priority) with configurable API key, base URL, and max results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nikolasdehor
approved these changes
Feb 28, 2026
nikolasdehor
left a comment
There was a problem hiding this comment.
Clean implementation that follows the existing SearchProvider pattern well. Priority placement (lowest, below DuckDuckGo) makes sense. A few suggestions: (1) Unbounded response read: io.ReadAll(resp.Body) has no size limit. Consider io.LimitReader(resp.Body, 110241024) to prevent OOM from malformed responses (PR #883 addresses the same pattern in WebFetch). (2) HTTP client per-request: createHTTPClient is called on every Search() invocation, creating a new client and transport each time. Consider creating it once in the constructor for HTTP connection reuse. (3) Tests: Even a basic test with a mock HTTP server would be valuable. LGTM.
- Cap response body read at 1MB via io.LimitReader to prevent OOM - Reuse HTTP client across searches instead of creating per request - Add mock HTTP server tests for success and error paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add Bocha AI as a new web search provider, appended at the lowest priority in the search provider chain.
Changes:
BochaConfigstruct andBochafield inWebToolsConfigBochaSearchProviderusing the Bocha AI web search API (api.bochaai.com/v1/web-search), supporting configurable API key, base URL, and max resultsWebSearchToolOptionsProvider priority remains: Perplexity > Brave > Tavily > DuckDuckGo > Bocha
Type of Change
AI Code Generation
Technical Context
Bocha AI provides a Bing-compatible web search API with optional summary generation. The implementation follows the existing
SearchProviderinterface pattern. Response format:data.webPages.value[]withname,url,snippet,summaryfields. Summaries are preferred over snippets when available, truncated at 500 chars.Test Environment
Checklist
🤖 Generated with Claude Code