{"record":{"id":"2bd277122e518683","repo":"microsoft/semantic-kernel","slug":"the-settings-must-be-an-googleaichatpromptexecutio","errorCode":null,"errorMessage":"The settings must be an GoogleAIChatPromptExecutionSettings.","messagePattern":"The settings must be an GoogleAIChatPromptExecutionSettings\\.","errorType":"exception","errorClass":"ServiceInvalidExecutionSettingsError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py","lineNumber":238,"sourceCode":"                location=self.service_settings.cloud_region,\n            ) as client:\n                async for chunk in _generate_content_stream(client):\n                    yield [\n                        self._create_streaming_chat_message_content(chunk, candidate, function_invoke_attempt)\n                        for candidate in chunk.candidates  # type: ignore\n                    ]\n        else:\n            with Client(api_key=self.service_settings.api_key.get_secret_value()) as client:  # type: ignore[union-attr]\n                async for chunk in _generate_content_stream(client):\n                    yield [\n                        self._create_streaming_chat_message_content(chunk, candidate, function_invoke_attempt)\n                        for candidate in chunk.candidates  # type: ignore\n                    ]\n\n    @override\n    def _verify_function_choice_settings(self, settings: \"PromptExecutionSettings\") -> None:\n        if not isinstance(settings, GoogleAIChatPromptExecutionSettings):\n            raise ServiceInvalidExecutionSettingsError(\"The settings must be an GoogleAIChatPromptExecutionSettings.\")\n        if settings.candidate_count is not None and settings.candidate_count > 1:\n            raise ServiceInvalidExecutionSettingsError(\n                \"Auto-invocation of tool calls may only be used with a \"\n                \"GoogleAIChatPromptExecutionSettings.candidate_count of 1.\"\n            )\n\n    @override\n    def _update_function_choice_settings_callback(\n        self,\n    ) -> Callable[[\"FunctionCallChoiceConfiguration\", \"PromptExecutionSettings\", FunctionChoiceType], None]:\n        return update_settings_from_function_choice_configuration\n\n    @override\n    def _reset_function_choice_settings(self, settings: \"PromptExecutionSettings\") -> None:\n        if hasattr(settings, \"tool_config\"):\n            settings.tool_config = None\n        if hasattr(settings, \"tools\"):\n            settings.tools = None","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py#L220-L256","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass an instance of GoogleAIChatPromptExecutionSettings (or omit settings to let the service create the correct default).","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.","When migrating code from the OpenAI connector, replace all PromptExecutionSettings references with GoogleAIChatPromptExecutionSettings for Google AI calls."],"exampleFix":"# before\nsettings = OpenAIPromptExecutionSettings()\nresult = await service.get_chat_message_content(chat_history, chat_settings=settings)\n\n# after\nfrom semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings\nsettings = GoogleAIChatPromptExecutionSettings()\nresult = await service.get_chat_message_content(chat_history, chat_settings=settings)","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings\n\nif not isinstance(settings, GoogleAIChatPromptExecutionSettings):\n    settings = GoogleAIChatPromptExecutionSettings.from_prompt_execution_settings(settings)","typeGuard":"from semantic_kernel.connectors.ai.google.google_ai.google_ai_prompt_execution_settings import GoogleAIChatPromptExecutionSettings\n\ndef is_google_ai_chat_settings(settings) -> bool:\n    return isinstance(settings, GoogleAIChatPromptExecutionSettings)","tryCatchPattern":null,"preventionTips":["Always instantiate the settings class returned by service.get_prompt_execution_settings_class().","Keep per-connector settings objects separate — do not share an OpenAI settings instance with a Google AI call.","When configuring function_choice_behavior on the Kernel, let the framework assign settings rather than passing a foreign type."],"tags":["google-ai","settings","function-calling","type-mismatch","auto-invocation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}