microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError

The settings must be an AzureAIInferenceChatPromptExecutionS

Error message

The settings must be an AzureAIInferenceChatPromptExecutionSettings.

What it means

Raised in _verify_function_choice_settings when the settings object passed to the Azure AI Inference chat completion service is not an AzureAIInferenceChatPromptExecutionSettings instance. The connector's function-choice/tool-call configuration logic is specific to that settings subclass, so a generic PromptExecutionSettings or a different connector's settings cannot be used for auto-invocation setup.

Source

Thrown at python/semantic_kernel/connectors/ai/azure_ai_inference/services/azure_ai_inference_chat_completion.py:200

                model=self.ai_model_id,
                messages=self._prepare_chat_history_for_request(chat_history),
                model_extras=settings.extra_parameters,
                **settings_dict,
            )

        async for chunk in response:
            if len(chunk.choices) == 0:
                continue
            chunk_metadata = self._get_metadata_from_response(chunk)
            yield [
                self._create_streaming_chat_message_content(chunk, choice, chunk_metadata, function_invoke_attempt)
                for choice in chunk.choices
            ]

    @override
    def _verify_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
        if not isinstance(settings, AzureAIInferenceChatPromptExecutionSettings):
            raise ServiceInvalidExecutionSettingsError(
                "The settings must be an AzureAIInferenceChatPromptExecutionSettings."
            )
        if settings.extra_parameters is not None and settings.extra_parameters.get("n", 1) > 1:
            # Currently only OpenAI models allow multiple completions but the Azure AI Inference service
            # does not expose the functionality directly. If users want to have more than 1 responses, they
            # need to configure `extra_parameters` with a key of "n" and a value greater than 1.
            raise ServiceInvalidExecutionSettingsError(
                "Auto invocation of tool calls may only be used with a single completion."
            )

    @override
    def _update_function_choice_settings_callback(
        self,
    ) -> Callable[["FunctionCallChoiceConfiguration", "PromptExecutionSettings", FunctionChoiceType], None]:
        return update_settings_from_function_call_configuration

    @override
    def _reset_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Use AzureAIInferenceChatPromptExecutionSettings for the Azure AI Inference chat completion service.
  2. Build settings per-connector rather than reusing one across vendors.
  3. If calling the base API directly, ensure the correct subclass is instantiated for the service in use.

Example fix

# before
from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings
settings = PromptExecutionSettings(service_id="azure")

# after
from semantic_kernel.connectors.ai.azure_ai_inference import AzureAIInferenceChatPromptExecutionSettings
settings = AzureAIInferenceChatPromptExecutionSettings(service_id="azure")
Defensive patterns

Strategy: type-guard

Validate before calling

from semantic_kernel.connectors.ai.azure_ai_inference import AzureAIInferenceChatPromptExecutionSettings

assert isinstance(settings, AzureAIInferenceChatPromptExecutionSettings), \
    "Use AzureAIInferenceChatPromptExecutionSettings for the Azure AI Inference chat service"

Type guard

from semantic_kernel.connectors.ai.azure_ai_inference import AzureAIInferenceChatPromptExecutionSettings

def is_azure_ai_settings(settings) -> bool:
    return isinstance(settings, AzureAIInferenceChatPromptExecutionSettings)

Try / catch

from semantic_kernel.exceptions import ServiceInvalidExecutionSettingsError
try:
    service._verify_function_choice_settings(settings)
except ServiceInvalidExecutionSettingsError:
    settings = AzureAIInferenceChatPromptExecutionSettings(**settings.model_dump())

Prevention

When it happens

Trigger: Passing a generic PromptExecutionSettings, an OpenAIChatPromptExecutionSettings, or any other settings type to an AzureAIInferenceChatCompletion method that triggers function-choice verification (i.e. when tools/auto-invocation are configured).

Common situations: Sharing a single settings object across connectors from different vendors; constructing settings via a factory that returns the base type; swapping the underlying connector without updating the settings class.

Related errors


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