crewAIInc/crewAI · error · BedrockValidationError

agent_alias_id cannot be empty

Error message

agent_alias_id cannot be empty

What it means

A BedrockValidationError raised when agent_alias_id is falsy (None or empty string). Bedrock's InvokeAgent API requires an alias ID (e.g. 'TSTALIASID' for a draft/test alias), so the tool validates it in __init__ and re-wraps the message as "Parameter validation failed: agent_alias_id cannot be empty".

Source

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

        )  # Use timestamp as session ID if not provided
        self.enable_trace = enable_trace
        self.end_session = end_session

        if description:
            self.description = description

        self._validate_parameters()

    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

View on GitHub (pinned to 754d7323be)

Solutions

  1. Use the test alias 'TSTALIASID' for a draft agent, or the real alias ID shown in the Bedrock console under Aliases.
  2. Prepare the agent in the AWS console first so an alias exists, then copy its ID.
  3. Wire config the same way as agent_id: os.environ['BEDROCK_AGENT_ALIAS_ID'].

Example fix

# before
tool = BedrockAgentTools(agent_id="ABCD123456", agent_alias_id="")

# after
tool = BedrockAgentTools(agent_id="ABCD123456", agent_alias_id="TSTALIASID")
Defensive patterns

Strategy: validation

Validate before calling

alias = os.environ.get("BEDROCK_AGENT_ALIAS_ID", "TSTALIASID")  # default to draft alias
assert alias, "agent_alias_id required"

Type guard

def is_agent_alias_id(v) -> bool:
    return isinstance(v, str) and len(v) > 0

Try / catch

try:
    tool = BedrockAgentTools(agent_id=aid, agent_alias_id=alias)
except BedrockValidationError as e:
    raise ValueError(f"Bad Bedrock alias config: {e}") from e

Prevention

When it happens

Trigger: Constructing BedrockAgentTools with agent_alias_id='' or None while agent_id passed its checks. Often happens when the developer only knows the agent_id and assumes the alias is optional.

Common situations: New Bedrock Agents users who have not created a prepared alias yet; reading the alias from a missing env var; or assuming the draft alias is auto-selected when omitted — this tool requires it explicitly.

Related errors


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