microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
The settings must be an OpenAIChatPromptExecutionSettings.
Error message
The settings must be an OpenAIChatPromptExecutionSettings.
What it means
Raised in _verify_function_choice_settings when the settings object passed to the tool-call auto-invocation path is not an instance of OpenAIChatPromptExecutionSettings. This method is overridden from the base AI service to enforce that only OpenAI-specific execution settings carry the function-call configuration needed for tool invocation.
Source
Thrown at python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py:143
content="",
choice_index=i,
inner_content=chunk,
ai_model_id=settings.ai_model_id,
metadata=chunk_metadata,
function_invoke_attempt=function_invoke_attempt,
)
for i in range(settings.number_of_responses or 1)
]
else:
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, OpenAIChatPromptExecutionSettings):
raise ServiceInvalidExecutionSettingsError("The settings must be an OpenAIChatPromptExecutionSettings.")
if settings.number_of_responses is not None and settings.number_of_responses > 1:
raise ServiceInvalidExecutionSettingsError(
"Auto-invocation of tool calls may only be used with a "
"OpenAIChatPromptExecutions.number_of_responses of 1."
)
@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:
if hasattr(settings, "tool_choice"):
settings.tool_choice = None
if hasattr(settings, "tools"):
settings.tools = NoneView on GitHub (pinned to c028a0c7dc)
Solutions
- Pass OpenAIChatPromptExecutionSettings to the completion call, not the base PromptExecutionSettings
- Use kernel.get_prompt_execution_settings_from_settings(settings) to auto-convert, or construct OpenAIChatPromptExecutionSettings directly
- Ensure your kernel's service_id mapping resolves to the OpenAI chat service when expecting OpenAI settings
Example fix
# before from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings settings = PromptExecutionSettings() # after from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings settings = OpenAIChatPromptExecutionSettings()
Defensive patterns
Strategy: type-guard
Validate before calling
from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings
if not isinstance(settings, OpenAIChatPromptExecutionSettings):
settings = OpenAIChatPromptExecutionSettings(**settings.model_dump() if hasattr(settings, 'model_dump') else {}) Type guard
from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings
def is_openai_chat_settings(settings) -> bool:
return isinstance(settings, OpenAIChatPromptExecutionSettings) Prevention
- Always construct provider-specific settings objects rather than passing the base class
- If your code handles multiple providers, branch on provider type before calling the completion method
When it happens
Trigger: Calling a chat completion with auto-function-invocation enabled but passing a generic PromptExecutionSettings or a non-OpenAI settings subclass (e.g., a custom settings class) instead of OpenAIChatPromptExecutionSettings.
Common situations: Building a multi-provider abstraction that passes a base PromptExecutionSettings to all services; accidentally using settings from a different connector (e.g., Azure-specific or a third-party connector) with the OpenAI chat completion service; misconfigured kernel service-resolver that returns the wrong settings type.
Related errors
- Auto-invocation of tool calls may only be used with a OpenAI
- Data is not available for {cityName}.
- No function result provided in the tool message.
- {nameof(executionSettings.ToolCallBehavior)} and {nameof(exe
- Unsupported function choice '{config.Choice}'.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/219b911f9162978a.
Report an issue: GitHub.