microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
Auto-invocation of tool calls may only be used with a OpenAI
Error message
Auto-invocation of tool calls may only be used with a OpenAIChatPromptExecutions.number_of_responses of 1.
What it means
Raised in _verify_function_choice_settings when auto-invocation of tool calls is enabled (function_choice configuration is set) but number_of_responses is greater than 1. The OpenAI API cannot reliably correlate tool-call requests/responses across multiple parallel completions, so Semantic Kernel blocks this combination at the configuration validation stage.
Source
Thrown at python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py:145
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 = None
# endregionView on GitHub (pinned to c028a0c7dc)
Solutions
- Set settings.number_of_responses = 1 (or leave it unset, which defaults to 1) when using auto-function-invocation
- If you need multiple responses, disable auto-invocation and handle tool calls manually in a loop
- Audit your settings object right before the call: if function calling is configured, force number_of_responses to 1
Example fix
# before settings = OpenAIChatPromptExecutionSettings(number_of_responses=3) # auto-invocation configured elsewhere -> raises at verify time # after settings = OpenAIChatPromptExecutionSettings() # number_of_responses defaults to 1 # or explicitly settings.number_of_responses = 1
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings
if isinstance(settings, OpenAIChatPromptExecutionSettings):
if settings.number_of_responses is not None and settings.number_of_responses > 1:
if hasattr(settings, 'function_choice_behavior') and settings.function_choice_behavior:
settings.number_of_responses = 1 # reconcile conflict Try / catch
from semantic_kernel.exceptions.service_exceptions import ServiceInvalidExecutionSettingsError
try:
await kernel.invoke(...)
except ServiceInvalidExecutionSettingsError as e:
if 'number_of_responses of 1' in str(e):
settings.number_of_responses = 1
await kernel.invoke(...) # retry Prevention
- Treat number_of_responses > 1 and function-calling as mutually exclusive by design
- Add a settings-validation helper that checks this invariant before the kernel call
When it happens
Trigger: Setting OpenAIChatPromptExecutionSettings.number_of_responses (OpenAI's n parameter) to a value > 1 while also configuring auto-function-invocation (e.g., FunctionChoiceBehavior.Auto with kernel/plugins registered).
Common situations: A developer sets n > 1 to get multiple candidate responses for selection, then later adds function calling to the same settings without resetting n; copying settings from a template that defaults number_of_responses to a higher value.
Related errors
- The settings must be an OpenAIChatPromptExecutionSettings.
- 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/97bb5e33b2465874.
Report an issue: GitHub.