microsoft/semantic-kernel · error · ServiceInitializationError
The specified type `{type_value}` is not supported. Allowed
Error message
The specified type `{type_value}` is not supported. Allowed types are: `auto`, `none`, `required`. What it means
Raised by FunctionChoiceBehavior.from_string when the provided string (lowercased) is not one of 'auto', 'none', or 'required'. from_string maps a behavior keyword to a behavior instance, so any other value is unsupported.
Source
Thrown at python/semantic_kernel/connectors/ai/function_choice_behavior.py:222
filters=filters,
**data,
)
@classmethod
def from_string(cls: type[_T], data: str) -> _T:
"""Create a FunctionChoiceBehavior from a string.
This method converts the provided string to a FunctionChoiceBehavior object
for the specified type.
"""
type_value = data.lower()
if type_value == "auto":
return cls.Auto()
if type_value == "none":
return cls.NoneInvoke()
if type_value == "required":
return cls.Required()
raise ServiceInitializationError(
f"The specified type `{type_value}` is not supported. Allowed types are: `auto`, `none`, `required`."
)
View on GitHub (pinned to c028a0c7dc)
Solutions
- Use exactly one of: 'auto', 'none', or 'required' (case-insensitive).
- Validate/whitelist the input string before calling from_string and surface a friendly error to the end user.
- If you need richer config (filters, auto_invoke), use FunctionChoiceBehavior.from_dict or the Auto/NoneInvoke/Required classmethods directly.
Example fix
# before
behavior = FunctionChoiceBehavior.from_string("tool")
# after
behavior = FunctionChoiceBehavior.from_string("required") Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {"auto", "none", "required"}
def is_valid_behavior_string(value: str) -> bool:
return isinstance(value, str) and value.lower() in ALLOWED Type guard
ALLOWED = {"auto", "none", "required"}
def is_function_choice_string(value: object) -> bool:
return isinstance(value, str) and value.lower() in ALLOWED Try / catch
from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError
try:
behavior = FunctionChoiceBehavior.from_string(raw)
except ServiceInitializationError as e:
if "not supported" in str(e):
raise ValueError(f"Invalid function choice '{raw}'. Use one of: auto, none, required") from e
raise Prevention
- Whitelist the input string to auto/none/required before calling from_string.
- Prefer FunctionChoiceBehavior.Auto/NoneInvoke/Required classmethods for compile-time safety.
- Validate config-driven strings at the boundary before they reach from_string.
When it happens
Trigger: Calling FunctionChoiceBehavior.from_string('tool'), from_string('always'), from_string(''), or any value outside the allowed set; a config-driven code path that feeds an unvalidated string into from_string.
Common situations: User config or CLI argument with a typo; expecting an OpenAI-style value like 'required'/'none'/'auto' but passing 'tools' or 'function'; migrating from an older API that accepted different keywords.
Related errors
- Values for filter key '{key}' are not lists.
- Invalid kernel selection. {selectedKernelName} is not a vali
- Azure AI Search tool definition must have both 'index_connec
- The option keys 'asset_identifiers' and 'asset_type' are req
- The option keys 'store_name' and 'data_sources' are required
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/20819997ac8269ce.
Report an issue: GitHub.