crewAIInc/crewAI · error · ValueError
Invalid parameters: {e}
Error message
Invalid parameters: {e} What it means
Raised by the Brave search tool base class when the request parameters fail validation against the tool's pydantic args_schema. Before validating, _run filters incoming params to known schema fields, so this fires when a retained field has an invalid type or value (e.g. count out of range, wrong enum for country/search_lang). The original pydantic ValidationError is chained as the cause and its text is embedded in the message.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py:258
# All retries exhausted — last_resp is always set when we reach here
_raise_for_error(last_resp or resp)
return {} # unreachable; satisfies return type
def _run(self, q: str | None = None, **params: Any) -> Any:
# Allow positional usage: tool.run("latest Brave browser features")
if q is not None:
params["q"] = q
params = self._common_payload_refinement(params)
schema_keys = self.args_schema.model_fields
payload_in = {k: v for k, v in params.items() if k in schema_keys}
try:
validated = self.args_schema(**payload_in)
except Exception as e:
raise ValueError(f"Invalid parameters: {e}") from e
# The subclass may have additional refinements to apply to the payload, such as goggles or other parameters
payload = self._refine_request_payload(validated.model_dump(exclude_none=True))
response = self._make_request(payload)
if not self.raw:
response = self._refine_response(response)
if self.save_file:
_save_results_to_file(json.dumps(response, indent=2))
return response
@abstractmethod
def _refine_request_payload(self, params: dict[str, Any]) -> dict[str, Any]:
"""Subclass must implement: transform validated params dict into API request params."""
raise NotImplementedError
View on GitHub (pinned to 754d7323be)
Solutions
- Read the embedded pydantic message: it names the exact field and constraint that failed.
- Check the tool's args_schema (e.g. BraveSearchToolSchema) for the field's type, enum, or numeric bounds and pass a conforming value.
- If an LLM is producing the call, ensure required fields get real values, not 'null'/''/[] placeholders.
- Pass the query positionally: tool.run('latest Brave browser features') to avoid misnamed kwargs.
Example fix
# before tool.run(q='crewai', count='ten', country='XX') # after from crewai_tools.tools.brave_search_tool import BraveSearchTool tool = BraveSearchTool() result = tool.run(q='crewai', count=10, country='us')
Defensive patterns
Strategy: validation
Validate before calling
from crewai_tools.tools.brave_search_tool import BraveSearchTool
tool = BraveSearchTool()
params = {"q": "crewai", "count": 10, "country": "us"}
# Dry-run the schema before the real call
tool.args_schema(**{k: v for k, v in params.items() if k in tool.args_schema.model_fields}) Try / catch
try:
result = tool.run(q=query, count=10)
except ValueError as e:
# message embeds the pydantic ValidationError details
if str(e).startswith("Invalid parameters:"):
log_bad_params(query, e)
result = tool.run(q=query) # retry with minimal safe params
else:
raise Prevention
- Pre-validate arguments against tool.args_schema before invoking the tool.
- Pass the search string positionally to avoid misnamed kwargs.
- Strip placeholder values ('null', '', []) from LLM-generated tool calls before dispatch.
When it happens
Trigger: Calling tool.run(q=..., count='ten') or passing an invalid country code like country='XX' or an unknown freshness/goggles value; an LLM agent filling a parameter with a placeholder like "null" or [] for a required field (the empty-value scrubber in _common_payload_refinement only strips optional fields).
Common situations: Agent frameworks (crewAI strict-mode schema pipelines mark all fields required, so LLMs stuff placeholders into required fields), typos in parameter names that collide with real fields, version changes where the args_schema gained stricter constraints.
Related errors
- Missing required input '{name}'{suffix}
- Invalid input '{location}': {error.get('msg')}
- Expected an async readable object with async read() method
- Expected a binary file-like object with read() and seek()
- Cannot convert {type(value).__name__} to file source
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/e1a43243fa5e9265.
Report an issue: GitHub.