crewAIInc/crewAI · error · BedrockValidationError
agent_alias_id must be a string
Error message
agent_alias_id must be a string
What it means
A BedrockValidationError raised when agent_alias_id is truthy but not a str. It is the type counterpart of the empty check for agent_alias_id and is re-wrapped by the except clause into "Parameter validation failed: agent_alias_id must be a string".
Source
Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py:84
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
try:
# Initialize the Bedrock Agent Runtime clientView on GitHub (pinned to 754d7323be)
Solutions
- Pass the string field: response['agentAlias']['agentAliasId'] if using boto3 responses.
- Coerce with str() at the boundary when the config source is not typed.
- Type your config with pydantic (agent_alias_id: str) so bad values fail at config load, not tool init.
Example fix
# before
alias = boto3.client("bedrock-agent").create_agent_alias(...) # dict
tool = BedrockAgentTools(agent_id="ABCD123456", agent_alias_id=alias)
# after
tool = BedrockAgentTools(agent_id="ABCD123456", agent_alias_id=alias["agentAlias"]["agentAliasId"]) Defensive patterns
Strategy: type-guard
Validate before calling
if alias is not None and not isinstance(alias, str):
alias = str(alias) 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:
if "agent_alias_id must be a string" in str(e):
tool = BedrockAgentTools(agent_id=aid, agent_alias_id=str(alias))
else:
raise Prevention
- Extract string fields from boto3 responses (['agentAlias']['agentAliasId']).
- Coerce non-str IDs with str() at the call site.
- Keep config typed with pydantic strings.
When it happens
Trigger: Passing a non-string truthy agent_alias_id (int, list, dict) to BedrockAgentTools — for example a numeric alias identifier loaded from config without string coercion.
Common situations: Machine-generated configs where IDs stay numeric; passing the whole alias object/dict returned by boto3's create_agent_alias instead of its 'agentAliasId' field.
Related errors
- agent_id must be a string
- session_id must be a string
- knowledge_base_id must be a string
- number_of_results must be an integer
- agent_id cannot be empty
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/0296f6f759100288.
Report an issue: GitHub.