Add bocha search tool#4329
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| return ( | ||
| f"Bocha API error: {data.get('msg', 'Unknown error')} " | ||
| f"(code: {data.get('code', 'N/A')})" | ||
| ) |
There was a problem hiding this comment.
API success check fails when code field absent
Medium Severity
The condition if data.get("code") != 200 incorrectly treats successful API responses as errors when the response JSON doesn't include a code field. If code is absent, data.get("code") returns None, and None != 200 evaluates to True, causing the tool to return an error message like "Bocha API error: Unknown error (code: N/A)" even for valid successful responses.
| from typing import Any, ClassVar | ||
|
|
||
| from crewai.tools import BaseTool, EnvVar | ||
| from pydantic import BaseModel, Field, field_validator |
There was a problem hiding this comment.
|
This PR is stale because it has been open for 45 days with no activity. |


BochaSearchTool Documentation
Description
This tool is designed to perform intelligent web searches with AI-powered summaries and rich metadata extraction. It utilizes the Bocha AI Search API, a REST API that provides comprehensive search results with detailed summaries, site names, icons, and crawl timestamps.
Installation
To incorporate this tool into your project, follow the installation instructions below:
pip install 'crewai[tools]'Example
The following example demonstrates how to initialize the tool.
Steps to Get Started
To effectively use the
BochaSearchTool, follow these steps:crewai[tools]package is installed in your Python environment.BOCHA_API_KEYto facilitate its use by the tool.Conclusion
By integrating the
BochaSearchToolinto Python projects, users gain the ability to conduct real-time, relevant searches across the internet directly from their applications. By adhering to the setup and usage guidelines provided, incorporating this tool into projects is streamlined and straightforward.Note
Medium Risk
Introduces a new external-networking tool that calls a third-party API using an env-provided secret, so failures/timeouts and response-shape changes could affect runtime behavior.
Overview
Adds a new
BochaSearchToolthat performs web searches via the Bocha AI Search API, requiringBOCHA_API_KEYand returning formatted results including title/URL/summary/site metadata.Includes user-facing documentation for installation, setup, and basic usage, and implements timeout/HTTP/connection/JSON error handling for the outbound request.
Written by Cursor Bugbot for commit 94058fe. This will update automatically on new commits. Configure here.