diff --git a/python/semantic_kernel/connectors/ai/azure_ai_inference/services/utils.py b/python/semantic_kernel/connectors/ai/azure_ai_inference/services/utils.py index 102f796c6030..7ad38b52af88 100644 --- a/python/semantic_kernel/connectors/ai/azure_ai_inference/services/utils.py +++ b/python/semantic_kernel/connectors/ai/azure_ai_inference/services/utils.py @@ -134,6 +134,9 @@ def _format_tool_message(message: ChatMessageContent) -> ToolMessage: Returns: The formatted tool message. """ + if len(message.items) == 0: + raise ValueError("Tool message has no items; expected exactly one FunctionResultContent item.") + if len(message.items) != 1: logger.warning( "Unsupported number of items in Tool message while formatting chat history for Azure AI"