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
- Use the test alias 'TSTALIASID' for a draft agent, or the real alias ID shown in the Bedrock console under Aliases.
- Prepare the agent in the AWS console first so an alias exists, then copy its ID.
- 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
- Use 'TSTALIASID' for draft agents; create and prepare a real alias for production.
- Treat agent_alias_id as mandatory config next to agent_id, not optional.
- Verify the alias exists in the Bedrock console before deploying.
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
- agent_id cannot be empty
- knowledge_base_id cannot be empty
- agent_id must be a string
- agent_alias_id must be a string
- session_id must be a string
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/c0c0e54872bd9d53.
Report an issue: GitHub.