From fe42415c2e38d47221d8bcefef67e7222355a279 Mon Sep 17 00:00:00 2001 From: "shuwen.wu" Date: Fri, 25 Sep 2026 16:11:10 +0800 Subject: [PATCH] fix: ChatHistory: preserve empty tool results with tool_call_id _prepare_for_add() checked 'content' (truthy check) when deciding to create FunctionResultContent for a TOOL message. An empty string content is falsy, so add_tool_message('', tool_call_id='...') silently dropped the tool_call_id and created an invalid message with no items. Change 'content' to 'content is not None' so an empty string result is accepted and the FunctionResultContent is created with the call_id. Fixes #14359. --- python/semantic_kernel/contents/chat_history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semantic_kernel/contents/chat_history.py b/python/semantic_kernel/contents/chat_history.py index a773c232c7bc..2be030a4c39e 100644 --- a/python/semantic_kernel/contents/chat_history.py +++ b/python/semantic_kernel/contents/chat_history.py @@ -219,7 +219,7 @@ def _prepare_for_add( """Prepare a message to be added to the history.""" kwargs["role"] = role - if role == AuthorRole.TOOL and content and not items: + if role == AuthorRole.TOOL and content is not None and not items: tool_call_id = kwargs.pop("tool_call_id", None) function_name = kwargs.pop("function_name", "unknown") function_result_content = FunctionResultContent(