crewAIInc/crewAI · error · BedrockValidationError

Parameter validation failed: {e!s}

Error message

Parameter validation failed: {e!s}

What it means

The wrapper message produced by the `except BedrockValidationError` clause in _validate_parameters: any of the individual parameter failures (empty/wrong-type agent_id, agent_alias_id, session_id) is re-raised as "Parameter validation failed: <original message>" with the original as __cause__. It is the single surfaced error for all constructor-time validation problems in the invoke-agent tool.

Source

Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py:90

    def _validate_parameters(self) -> None:
        """Validate the parameters according to AWS API requirements."""
        try:
            if not self.agent_id:
                raise BedrockValidationError("agent_id cannot be empty")
            if not isinstance(self.agent_id, str):
                raise BedrockValidationError("agent_id must be a string")

            if not self.agent_alias_id:
                raise BedrockValidationError("agent_alias_id cannot be empty")
            if not isinstance(self.agent_alias_id, str):
                raise BedrockValidationError("agent_alias_id must be a string")

            if self.session_id and not isinstance(self.session_id, str):
                raise BedrockValidationError("session_id must be a string")

        except BedrockValidationError as e:
            raise BedrockValidationError(f"Parameter validation failed: {e!s}") from e

    def _run(self, query: str) -> str:
        try:
            import boto3
            from botocore.exceptions import ClientError
        except ImportError as e:
            raise ImportError(
                "`boto3` package not found, please run `uv add boto3`"
            ) from e

        try:
            # Initialize the Bedrock Agent Runtime client
            bedrock_agent = boto3.client(
                "bedrock-agent-runtime",
                region_name=os.getenv(
                    "AWS_REGION", os.getenv("AWS_DEFAULT_REGION", "us-west-2")
                ),
            )

View on GitHub (pinned to 754d7323be)

Solutions

  1. Read the text after 'Parameter validation failed:' — it names the exact field and problem.
  2. Fix that field per its specific rule (non-empty str agent_id, non-empty str agent_alias_id, optional str session_id).
  3. Validate inputs before construction (see validation code) so the error never fires.
Defensive patterns

Strategy: validation

Validate before calling

import re

def validate_invoke_agent_cfg(agent_id, agent_alias_id, session_id=None) -> None:
    assert isinstance(agent_id, str) and agent_id, "agent_id must be non-empty str"
    assert isinstance(agent_alias_id, str) and agent_alias_id, "agent_alias_id must be non-empty str"
    assert session_id is None or isinstance(session_id, str), "session_id must be str"

Try / catch

try:
    tool = BedrockAgentTools(agent_id=aid, agent_alias_id=alias, session_id=sid)
except BedrockValidationError as e:
    # message suffix names the exact bad field
    raise ValueError(f"Bedrock agent tool misconfigured: {e}") from e

Prevention

When it happens

Trigger: Any BedrockAgentTools construction whose agent_id/agent_alias_id/session_id fails empty-check or isinstance-check — the inner raise at lines 77-87 is caught here and re-wrapped. The original specific message appears after the colon.

Common situations: Generic wrapper users see in stack traces when any parameter is wrong; diagnosing requires reading the suffix (e.g. 'Parameter validation failed: agent_id cannot be empty') rather than the wrapper itself.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/676b1eaab5c77078. Report an issue: GitHub.