{"record":{"id":"092319b11c18df94","repo":"crewAIInc/crewAI","slug":"session-id-must-be-a-string","errorCode":null,"errorMessage":"session_id must be a string","messagePattern":"session_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":87,"sourceCode":"            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(\n                \"`boto3` package not found, please run `uv add boto3`\"\n            ) from e\n\n        try:\n            # Initialize the Bedrock Agent Runtime client\n            bedrock_agent = boto3.client(\n                \"bedrock-agent-runtime\",\n                region_name=os.getenv(","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py#L69-L105","documentation":"A BedrockValidationError raised when an optional session_id is provided but is not a string. session_id is optional (the check is `if self.session_id and not isinstance(...)`), so the error only fires when a truthy non-string value is supplied.","triggerScenarios":"Constructing the tool with session_id as an int/UUID object/list — e.g. `session_id=uuid.uuid4()` (UUID object, not str) or a numeric session key from a database.","commonSituations":"Generating session IDs with uuid.uuid4() and forgetting str(); passing a pandas/numpy integer session key; reusing an internal session object instead of its string identifier.","solutions":["Convert: `session_id=str(uuid.uuid4())`.","If reusing an AWS-returned sessionId from a previous InvokeAgent response, take the raw string field.","Omit session_id entirely if you do not need cross-invocation memory."],"exampleFix":"# before\ntool = BedrockAgentTools(agent_id=\"ABCD123456\", agent_alias_id=\"TSTALIASID\", session_id=uuid.uuid4())\n\n# after\ntool = BedrockAgentTools(agent_id=\"ABCD123456\", agent_alias_id=\"TSTALIASID\", session_id=str(uuid.uuid4()))","handlingStrategy":"type-guard","validationCode":"if session_id is not None and not isinstance(session_id, str):\n    session_id = str(session_id)","typeGuard":"def is_session_id(v) -> bool:\n    return v is None or isinstance(v, str)","tryCatchPattern":"try:\n    tool = BedrockAgentTools(agent_id=aid, agent_alias_id=alias, session_id=sid)\nexcept BedrockValidationError as e:\n    if \"session_id must be a string\" in str(e):\n        tool = BedrockAgentTools(agent_id=aid, agent_alias_id=alias, session_id=str(sid))\n    else:\n        raise","preventionTips":["Always wrap generated IDs: str(uuid.uuid4()).","Omit session_id when session continuity is not needed.","Reuse AWS-returned sessionId strings verbatim, not re-wrapped objects."],"tags":["aws","bedrock","validation","type-error","session"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}