{"record":{"id":"bba4f04754ea9c20","repo":"microsoft/semantic-kernel","slug":"only-functionchoicetype-auto-is-supported","errorCode":null,"errorMessage":"Only FunctionChoiceType.AUTO is supported.","messagePattern":"Only FunctionChoiceType\\.AUTO is supported\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/bedrock/bedrock_agent_base.py","lineNumber":91,"sourceCode":"            \"bedrock_client\": bedrock_client or boto3.client(\"bedrock-agent\"),\n            **kwargs,\n        }\n        if function_choice_behavior:\n            args[\"function_choice_behavior\"] = function_choice_behavior\n\n        super().__init__(**args)\n\n    @field_validator(\"function_choice_behavior\", mode=\"after\")\n    @classmethod\n    def validate_function_choice_behavior(\n        cls, function_choice_behavior: FunctionChoiceBehavior | None\n    ) -> FunctionChoiceBehavior | None:\n        \"\"\"Validate the function choice behavior.\"\"\"\n        if function_choice_behavior and function_choice_behavior.type_ != FunctionChoiceType.AUTO:\n            # Users cannot specify REQUIRED or NONE for the Bedrock agents.\n            # Please note that the function choice behavior only control if the kernel will automatically\n            # execute the functions the agent requests. It does not control the behavior of the agent.\n            raise ValueError(\"Only FunctionChoiceType.AUTO is supported.\")\n        return function_choice_behavior\n\n    def __repr__(self):\n        \"\"\"Return the string representation of the Bedrock Agent.\"\"\"\n        return f\"{self.agent_model}\"\n\n    # region Agent Management\n\n    async def prepare_agent_and_wait_until_prepared(self) -> None:\n        \"\"\"Prepare the agent for use.\"\"\"\n        if not self.agent_model.agent_id:\n            raise ValueError(\"Agent does not exist. Please create the agent before preparing it.\")\n\n        try:\n            await run_in_executor(\n                None,\n                partial(\n                    self.bedrock_client.prepare_agent,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/bedrock/bedrock_agent_base.py#L73-L109","documentation":"Raised by the Pydantic field_validator on BedrockAgentBase.function_choice_behavior. Amazon Bedrock agents always decide on their own whether to call functions; the FunctionChoiceBehavior in Semantic Kernel only controls whether the kernel auto-executes those requests. Therefore only FunctionChoiceType.AUTO is permitted — REQUIRED and NONE have no meaning for Bedrock and are rejected.","triggerScenarios":"Triggered during model validation when constructing BedrockAgent or BedrockAgentBase with function_choice_behavior=FunctionChoiceBehavior.Required() or FunctionChoiceBehavior.None().","commonSituations":"Porting config from a ChatCompletionAgent that used Required/None; explicitly setting function_choice_behavior assuming it controls agent behavior; copying a FunctionChoiceBehavior instance across agent types.","solutions":["Use FunctionChoiceBehavior.Auto() (the default) for BedrockAgent, or omit the argument entirely.","Understand that for Bedrock, function calling is always agent-driven; you only control auto-execution via AUTO.","Remove any Required/None behavior objects when switching to BedrockAgent."],"exampleFix":"// before\nagent = BedrockAgent(\n    model,\n    function_choice_behavior=FunctionChoiceBehavior.Required(),  # rejected\n)\n\n// after\nagent = BedrockAgent(\n    model,\n    function_choice_behavior=FunctionChoiceBehavior.Auto(),  # or omit entirely\n)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType\n\ndef assert_auto_only(fcb) -> None:\n    if fcb is not None and fcb.type_ != FunctionChoiceType.AUTO:\n        raise ValueError(\n            \"BedrockAgent only supports FunctionChoiceType.AUTO; \"\n            f\"got {fcb.type_}. Use FunctionChoiceBehavior.Auto().\"\n        )","typeGuard":"from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType\n\ndef is_bedrock_compatible_fcb(fcb) -> bool:\n    return fcb is None or fcb.type_ == FunctionChoiceType.AUTO","tryCatchPattern":"try:\n    agent = BedrockAgent(model, function_choice_behavior=fcb)\nexcept ValueError as e:\n    if \"Only FunctionChoiceType.AUTO is supported\" in str(e):\n        agent = BedrockAgent(model, function_choice_behavior=FunctionChoiceBehavior.Auto())\n    else:\n        raise","preventionTips":["Always use FunctionChoiceBehavior.Auto() (or omit it) for BedrockAgent.","Do not reuse Required/None behavior objects from other agent types.","Validate the behavior type before constructing the agent when config is dynamic."],"tags":["bedrock","function-calling","function-choice-behavior","validation","pydantic"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}