microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
Auto invocation of tool calls may only be used with a single
Error message
Auto invocation of tool calls may only be used with a single completion.
What it means
Raised by _verify_function_choice_settings when auto-invocation of tool calls is enabled and extra_parameters contains 'n' greater than 1. Auto-invocation needs a single deterministic completion to feed the tool result back into the conversation loop; requesting multiple completions (n>1) makes the result ambiguous and the loop cannot proceed.
Source
Thrown at python/semantic_kernel/connectors/ai/azure_ai_inference/services/azure_ai_inference_chat_completion.py:207
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:
if hasattr(settings, "tool_choice"):
settings.tool_choice = None
if hasattr(settings, "tools"):
settings.tools = None
@override
def _prepare_chat_history_for_request(View on GitHub (pinned to c028a0c7dc)
Solutions
- If you need auto tool-invocation, set extra_parameters n to 1 (or remove the 'n' key).
- If you need multiple completions (n>1), disable auto-invocation (function_choice_behavior=None) and handle tool calls manually.
- Split into two separate calls: one for multiple completions, one for tool-augmented single completion.
Example fix
# before
settings.extra_parameters = {"n": 3}
settings.function_choice_behavior = "auto"
# after (auto-invocation path)
settings.extra_parameters = {"n": 1}
settings.function_choice_behavior = "auto" Defensive patterns
Strategy: validation
Validate before calling
def ensure_single_completion_for_auto_invoke(settings):
if settings.function_choice_behavior and settings.function_choice_behavior.auto_invoke:
n = (settings.extra_parameters or {}).get("n", 1)
assert n == 1, "Auto-invocation requires n == 1"
return settings Type guard
def auto_invoke_with_single_completion(settings) -> bool:
ep = settings.extra_parameters or {}
return ep.get("n", 1) == 1 or not (
settings.function_choice_behavior and settings.function_choice_behavior.auto_invoke
) Try / catch
from semantic_kernel.exceptions import ServiceInvalidExecutionSettingsError
try:
service._verify_function_choice_settings(settings)
except ServiceInvalidExecutionSettingsError as e:
if "single completion" in str(e):
settings.extra_parameters = {"n": 1} Prevention
- Keep n == 1 when auto-invocation is on.
- Disable auto-invocation if you need n > 1.
- Validate extra_parameters before enabling tools.
When it happens
Trigger: Enabling function_choice_behavior='auto' (or required) while also setting extra_parameters={'n': N} with N>1 on AzureAIInferenceChatPromptExecutionSettings. Azure AI Inference does not expose n directly, so users configure it via extra_parameters.
Common situations: Wanting multiple candidate responses (n>1) and tool use in the same call; leaving extra_parameters from a prior config that set n for non-tool calls; misunderstanding that auto-invocation implies n=1.
Related errors
- The settings must be an AzureAIInferenceChatPromptExecutionS
- No FunctionResultContent found in the message items
- Tool message found without a preceding message.
- Tool message found after a user or system message.
- If response_format has type 'json_schema', 'json_schema' mus
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/382d26b464b3025d.
Report an issue: GitHub.