microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError

The settings must be an GoogleAIChatPromptExecutionSettings.

Error message

The settings must be an GoogleAIChatPromptExecutionSettings.

What it means

Raised by _verify_function_choice_settings when the PromptExecutionSettings passed to a chat completion call with tool/function calling enabled is not a GoogleAIChatPromptExecutionSettings instance. Function-choice auto-invocation requires the connector-specific settings class because it carries Google AI fields like tool_config and tools. The base class method is overridden to enforce this type before proceeding.

Source

Thrown at python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py:238

                location=self.service_settings.cloud_region,
            ) as client:
                async for chunk in _generate_content_stream(client):
                    yield [
                        self._create_streaming_chat_message_content(chunk, candidate, function_invoke_attempt)
                        for candidate in chunk.candidates  # type: ignore
                    ]
        else:
            with Client(api_key=self.service_settings.api_key.get_secret_value()) as client:  # type: ignore[union-attr]
                async for chunk in _generate_content_stream(client):
                    yield [
                        self._create_streaming_chat_message_content(chunk, candidate, function_invoke_attempt)
                        for candidate in chunk.candidates  # type: ignore
                    ]

    @override
    def _verify_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
        if not isinstance(settings, GoogleAIChatPromptExecutionSettings):
            raise ServiceInvalidExecutionSettingsError("The settings must be an GoogleAIChatPromptExecutionSettings.")
        if settings.candidate_count is not None and settings.candidate_count > 1:
            raise ServiceInvalidExecutionSettingsError(
                "Auto-invocation of tool calls may only be used with a "
                "GoogleAIChatPromptExecutionSettings.candidate_count of 1."
            )

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

    @override
    def _reset_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
        if hasattr(settings, "tool_config"):
            settings.tool_config = None
        if hasattr(settings, "tools"):
            settings.tools = None

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass an instance of GoogleAIChatPromptExecutionSettings (or omit settings to let the service create the correct default).
  2. If using the Kernel, let the service's get_prompt_execution_settings_class() provide the right type instead of hardcoding a different connector's settings class.
  3. When migrating code from the OpenAI connector, replace all PromptExecutionSettings references with GoogleAIChatPromptExecutionSettings for Google AI calls.

Example fix

# before
settings = OpenAIPromptExecutionSettings()
result = await service.get_chat_message_content(chat_history, chat_settings=settings)

# after
from semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings
settings = GoogleAIChatPromptExecutionSettings()
result = await service.get_chat_message_content(chat_history, chat_settings=settings)
Defensive patterns

Strategy: type-guard

Validate before calling

from semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings

if not isinstance(settings, GoogleAIChatPromptExecutionSettings):
    settings = GoogleAIChatPromptExecutionSettings.from_prompt_execution_settings(settings)

Type guard

from semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings

def is_google_ai_chat_settings(settings) -> bool:
    return isinstance(settings, GoogleAIChatPromptExecutionSettings)

Prevention

When it happens

Trigger: Calling chat() or get_chat_message_content() with function_choice_behavior configured (e.g. FunctionChoiceBehavior.Auto()) but passing settings that are a different connector's class (e.g. OpenAIPromptExecutionSettings, AzureChatPromptExecutionSettings) or a bare PromptExecutionSettings.

Common situations: Reusing settings objects across connectors when switching from OpenAI to Google AI without re-instantiating them; calling kernel.add_service() with one connector but passing settings from another; manually constructing a PromptExecutionSettings instead of the Google AI subclass.

Related errors


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