microsoft/semantic-kernel · error · ValueError

Only FunctionChoiceType.AUTO is supported.

Error message

Only FunctionChoiceType.AUTO is supported.

What it means

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.

Solutions

  1. Use FunctionChoiceBehavior.Auto() (the default) for BedrockAgent, or omit the argument entirely.
  2. Understand that for Bedrock, function calling is always agent-driven; you only control auto-execution via AUTO.
  3. Remove any Required/None behavior objects when switching to BedrockAgent.

Example fix

// before
agent = BedrockAgent(
    model,
    function_choice_behavior=FunctionChoiceBehavior.Required(),  # rejected
)

// after
agent = BedrockAgent(
    model,
    function_choice_behavior=FunctionChoiceBehavior.Auto(),  # or omit entirely
)
Defensive patterns

Strategy: validation

Validate before calling

from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType

def assert_auto_only(fcb) -> None:
    if fcb is not None and fcb.type_ != FunctionChoiceType.AUTO:
        raise ValueError(
            "BedrockAgent only supports FunctionChoiceType.AUTO; "
            f"got {fcb.type_}. Use FunctionChoiceBehavior.Auto()."
        )

Type guard

from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType

def is_bedrock_compatible_fcb(fcb) -> bool:
    return fcb is None or fcb.type_ == FunctionChoiceType.AUTO

Try / catch

try:
    agent = BedrockAgent(model, function_choice_behavior=fcb)
except ValueError as e:
    if "Only FunctionChoiceType.AUTO is supported" in str(e):
        agent = BedrockAgent(model, function_choice_behavior=FunctionChoiceBehavior.Auto())
    else:
        raise

Prevention

When it happens

Trigger: Triggered during model validation when constructing BedrockAgent or BedrockAgentBase with function_choice_behavior=FunctionChoiceBehavior.Required() or FunctionChoiceBehavior.None().

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/bba4f04754ea9c20. Report an issue: GitHub.

Appendix: source

Thrown at python/semantic_kernel/agents/bedrock/bedrock_agent_base.py:91

            "bedrock_client": bedrock_client or boto3.client("bedrock-agent"),
            **kwargs,
        }
        if function_choice_behavior:
            args["function_choice_behavior"] = function_choice_behavior

        super().__init__(**args)

    @field_validator("function_choice_behavior", mode="after")
    @classmethod
    def validate_function_choice_behavior(
        cls, function_choice_behavior: FunctionChoiceBehavior | None
    ) -> FunctionChoiceBehavior | None:
        """Validate the function choice behavior."""
        if function_choice_behavior and function_choice_behavior.type_ != FunctionChoiceType.AUTO:
            # Users cannot specify REQUIRED or NONE for the Bedrock agents.
            # Please note that the function choice behavior only control if the kernel will automatically
            # execute the functions the agent requests. It does not control the behavior of the agent.
            raise ValueError("Only FunctionChoiceType.AUTO is supported.")
        return function_choice_behavior

    def __repr__(self):
        """Return the string representation of the Bedrock Agent."""
        return f"{self.agent_model}"

    # region Agent Management

    async def prepare_agent_and_wait_until_prepared(self) -> None:
        """Prepare the agent for use."""
        if not self.agent_model.agent_id:
            raise ValueError("Agent does not exist. Please create the agent before preparing it.")

        try:
            await run_in_executor(
                None,
                partial(
                    self.bedrock_client.prepare_agent,

View on GitHub (pinned to c028a0c7dc)