{"record":{"id":"9e925de6863c3ff7","repo":"crewAIInc/crewAI","slug":"agent-id-must-be-a-string","errorCode":null,"errorMessage":"agent_id must be a string","messagePattern":"agent_id must be a string","errorType":"validation","errorClass":"BedrockValidationError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py","lineNumber":79,"sourceCode":"        self.agent_alias_id = agent_alias_id or os.getenv(\"BEDROCK_AGENT_ALIAS_ID\")\n        self.session_id = session_id or str(\n            int(time.time())\n        )  # Use timestamp as session ID if not provided\n        self.enable_trace = enable_trace\n        self.end_session = end_session\n\n        if description:\n            self.description = description\n\n        self._validate_parameters()\n\n    def _validate_parameters(self) -> None:\n        \"\"\"Validate the parameters according to AWS API requirements.\"\"\"\n        try:\n            if not self.agent_id:\n                raise BedrockValidationError(\"agent_id cannot be empty\")\n            if not isinstance(self.agent_id, str):\n                raise BedrockValidationError(\"agent_id must be a string\")\n\n            if not self.agent_alias_id:\n                raise BedrockValidationError(\"agent_alias_id cannot be empty\")\n            if not isinstance(self.agent_alias_id, str):\n                raise BedrockValidationError(\"agent_alias_id must be a string\")\n\n            if self.session_id and not isinstance(self.session_id, str):\n                raise BedrockValidationError(\"session_id must be a string\")\n\n        except BedrockValidationError as e:\n            raise BedrockValidationError(f\"Parameter validation failed: {e!s}\") from e\n\n    def _run(self, query: str) -> str:\n        try:\n            import boto3\n            from botocore.exceptions import ClientError\n        except ImportError as e:\n            raise ImportError(","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py#L61-L97","documentation":"A BedrockValidationError raised when agent_id is truthy but not a str instance (e.g. an int or a list). The empty check passed, but AWS requires agent_id to be a string, so isinstance(self.agent_id, str) fails. The outer except re-wraps it as \"Parameter validation failed: agent_id must be a string\".","triggerScenarios":"Passing agent_id as a non-string truthy value: an int from JSON config, a list/tuple from a misparsed YAML, or a dict. Constructed tools validate in __init__, so the error appears at creation time.","commonSituations":"Config parsed with a numeric-looking ID kept as a number, programmatic ID from another SDK returned as bytes/enum, or passing a list of IDs intending multi-agent use (not supported by this tool).","solutions":["Convert to str at the call site: `agent_id=str(agent_id)`.","Fix the config source so the ID is quoted as a string (YAML/JSON schema or pydantic model with agent_id: str).","Unwrap collections: if you have a list, pick one ID — the tool invokes a single agent."],"exampleFix":"# before\ntool = BedrockAgentTools(agent_id=1234567890, agent_alias_id=\"TSTALIASID\")\n\n# after\ntool = BedrockAgentTools(agent_id=str(1234567890), agent_alias_id=\"TSTALIASID\")","handlingStrategy":"type-guard","validationCode":"agent_id = str(agent_id).strip()\nif not agent_id:\n    raise ValueError(\"agent_id empty\")","typeGuard":"def is_agent_id(v) -> bool:\n    return isinstance(v, str) and len(v) > 0","tryCatchPattern":"try:\n    tool = BedrockAgentTools(agent_id=agent_id, agent_alias_id=alias)\nexcept BedrockValidationError as e:\n    if \"agent_id must be a string\" in str(e):\n        tool = BedrockAgentTools(agent_id=str(agent_id), agent_alias_id=alias)\n    else:\n        raise","preventionTips":["Coerce IDs to str at config boundaries (str(agent_id)).","Type config models so non-strings fail at load time.","Never pass boto3 response dicts where an ID string is expected."],"tags":["aws","bedrock","validation","type-error"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}