Skip to content

Add bocha search tool#4329

Open
weijintaocode wants to merge 1 commit intocrewAIInc:mainfrom
weijintaocode:addbocha
Open

Add bocha search tool#4329
weijintaocode wants to merge 1 commit intocrewAIInc:mainfrom
weijintaocode:addbocha

Conversation

@weijintaocode
Copy link
Copy Markdown

@weijintaocode weijintaocode commented Feb 2, 2026

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.

from crewai_tools import BochaSearchTool

# Initialize the tool for internet searching capabilities
tool = BochaSearchTool()

Steps to Get Started

To effectively use the BochaSearchTool, follow these steps:

  1. Package Installation: Confirm that the crewai[tools] package is installed in your Python environment.
  2. API Key Acquisition: Acquire a API key here.
  3. Environment Configuration: Store your obtained API key in an environment variable named BOCHA_API_KEY to facilitate its use by the tool.

Conclusion

By integrating the BochaSearchTool into 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 BochaSearchTool that performs web searches via the Bocha AI Search API, requiring BOCHA_API_KEY and 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.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')})"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

from typing import Any, ClassVar

from crewai.tools import BaseTool, EnvVar
from pydantic import BaseModel, Field, field_validator
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports clutter the module

Low Severity

Three imports are unused: datetime (line 1), ClassVar (line 3), and field_validator (line 6). These are imported but never referenced anywhere in the code. Only Any from typing and BaseModel, Field from pydantic are actually used.

Fix in Cursor Fix in Web

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 45 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant