[BUG] BraveSearchTool ignores the documented api_key argument
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/brave_search_tool.py から始めてください。そこでは BraveSearchTool.__init__ は BRAVE_API_KEY のみを確認し、_run は環境を読み取ります。同じツールパッケージ内の BraveSearchToolBase を読み、api_key をどのように宣言し、環境より優先しているかを確認してから、BraveSearchTool がそのパターンに従うようにしてください。issue のスクリプトで再現し、brave search tool のテストを実行してください。完了とは、api_key= が環境変数なしで機能し、両方が設定されている場合に優先されることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Description
The docs for BraveSearchTool say the API key can be passed directly:
docs/edge/en/tools/search-research/bravesearchtool.mdx:45- "store your key asBRAVE_API_KEY, or pass it directly via theapi_keyparameter"docs/edge/en/tools/search-research/bravesearchtool.mdx:115-| api_key | str \| None | None | Brave API key. Falls back to the BRAVE_API_KEY environment variable. |
The exported class (lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/brave_search_tool.py, imported as crewai_tools.BraveSearchTool) has no api_key field, so pydantic silently drops the argument, and its __init__ only checks the environment:
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
if "BRAVE_API_KEY" not in os.environ:
raise ValueError(
"BRAVE_API_KEY environment variable is required for BraveSearchTool"
)
and _run sends os.environ["BRAVE_API_KEY"] in the X-Subscription-Token header.
The newer Brave tools (BraveWebSearchTool, BraveNewsSearchTool, ...) inherit BraveSearchToolBase, whose constructor does accept api_key= and use it over the environment - so the same documented behavior works for them but not for BraveSearchTool itself.
Steps to Reproduce
import os
os.environ.pop("BRAVE_API_KEY", None)
from crewai_tools import BraveSearchTool
tool = BraveSearchTool(api_key="explicit-key")
Raises:
ValueError: BRAVE_API_KEY environment variable is required for BraveSearchTool
With BRAVE_API_KEY set to env-key and BraveSearchTool(api_key="explicit-key"), construction succeeds but the tool has no api_key attribute and the request still sends env-key.
Expected Behavior
BraveSearchTool(api_key=...) should work without the environment variable and should take precedence over it, with BRAVE_API_KEY kept as the fallback - as documented and as BraveSearchToolBase already implements for the other Brave tools.
AI assistance
I used an AI coding agent to investigate, reproduce, and prepare this report, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
- 主要言語
- Python
- スター
- 61.2k
- フォーク
- 9.2k
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 228
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crewAIInc/crewAI のほかの issue
-
[BUG] crewai tool create/install/login exit 0 when they fail対応中かも @Kiko0301 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
APIKeyAuth cookie mode overwrites existing Cookie headers対応中かも @Kiko0301 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
crewAIInc/crewAI#9706 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Agent.copy() shares the LLM's additional_params and token usage対応中かも @HanYuanLu が 5 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
crewAIInc/crewAI#9587 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[FEATURE] Document a single-agent workflow with skills対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
crewAIInc/crewAI の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
NL-BioImaging/biomero#136 ·
メンテナーはふだん 1 日以内に返信
-
Grayscale PNGs with partial transparency can turn gray pixels white対応中かも @ktz03 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
floorianmb/tidywise#5 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
eclipse-score/tools#82 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信