microsoft/semantic-kernel · error · ServiceInitializationError
Values for filter key '{key}' are not lists.
Error message
Values for filter key '{key}' are not lists. What it means
Raised by the internal _combine_filter_dicts helper when merging function-choice filter dictionaries: it expects every value to be a list of strings, but encountered a non-list value for a given key. The helper unions filter keys across dicts and deduplicates list entries, so a scalar value cannot be merged.
Source
Thrown at python/semantic_kernel/connectors/ai/function_calling_utils.py:97
def _combine_filter_dicts(*dicts: dict[str, list[str]]) -> dict:
"""Combine multiple filter dictionaries with list values into one dictionary.
This method is ensuring unique values while preserving order.
"""
combined_filters = {}
keys = set().union(*(d.keys() for d in dicts))
for key in keys:
combined_functions: OrderedDict[str, None] = OrderedDict()
for d in dicts:
if key in d:
if isinstance(d[key], list):
for item in d[key]:
combined_functions[item] = None
else:
raise ServiceInitializationError(f"Values for filter key '{key}' are not lists.")
combined_filters[key] = list(combined_functions.keys())
return combined_filters
def merge_function_results(
messages: list["ChatMessageContent"],
) -> list["ChatMessageContent"]:
"""Combine multiple function result content types to one chat message content type.
This method combines the FunctionResultContent items from separate ChatMessageContent messages,
and is used in the event that the `context.terminate = True` condition is met.
"""
from semantic_kernel.contents.chat_message_content import ChatMessageContent
from semantic_kernel.contents.function_result_content import FunctionResultContent
items: list[Any] = []
for message in messages:View on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure every filter value is a list of strings, e.g. {'included_functions': ['plugin-function']}.
- Normalize scalar inputs to single-element lists before calling FunctionChoiceBehavior.from_dict.
- Validate the filters dict shape before constructing the behavior.
Example fix
# before
filters = {"included_functions": "search-web"}
behavior = FunctionChoiceBehavior.from_dict({"type": "auto", "filters": filters})
# after
filters = {"included_functions": ["search-web"]}
behavior = FunctionChoiceBehavior.from_dict({"type": "auto", "filters": filters}) Defensive patterns
Strategy: validation
Validate before calling
def filters_values_are_lists(filters: dict) -> bool:
return all(isinstance(v, list) and all(isinstance(x, str) for x in v) for v in filters.values()) Type guard
from typing import Any
def is_valid_filter_dict(filters: Any) -> bool:
return isinstance(filters, dict) and all(isinstance(v, list) for v in filters.values()) Try / catch
from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError
try:
behavior = FunctionChoiceBehavior.from_dict({"type": "auto", "filters": filters})
except ServiceInitializationError as e:
if "are not lists" in str(e):
filters = {k: ([v] if isinstance(v, str) else v) for k, v in filters.items()}
behavior = FunctionChoiceBehavior.from_dict({"type": "auto", "filters": filters})
else:
raise Prevention
- Always use list-of-strings values in function-choice filter dicts.
- Normalize scalar strings to single-element lists before constructing the behavior.
- Validate the filter dict shape before passing to from_dict.
When it happens
Trigger: FunctionChoiceBehavior.from_dict or any caller of _combine_filter_dicts passing filter dicts whose values are not lists, e.g. {'included_functions': 'my-func'} instead of {'included_functions': ['my-func']}.
Common situations: Hand-building a filters dict with scalar values; deserializing a config/YAML where a single function name was given as a string rather than a one-element list; merging a user-supplied filters dict that did not validate shapes.
Related errors
- The specified type `{type_value}` is not supported. Allowed
- 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/8ae7c985613665a5.
Report an issue: GitHub.