From 9be863fefa03456508f7abd605d5cb78ca5a5bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E8=90=8C=E9=97=B7=E6=B2=B9=E7=93=B6?= <253605712@qq.com> Date: Tue, 13 Jan 2026 12:46:33 +0800 Subject: [PATCH] fix: missing content if assistant message with tool_calls (#30083) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- api/core/agent/fc_agent_runner.py | 4 +--- api/core/model_runtime/entities/message_entities.py | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/api/core/agent/fc_agent_runner.py b/api/core/agent/fc_agent_runner.py index 68d14ad027..7c5c9136a7 100644 --- a/api/core/agent/fc_agent_runner.py +++ b/api/core/agent/fc_agent_runner.py @@ -188,7 +188,7 @@ class FunctionCallAgentRunner(BaseAgentRunner): ), ) - assistant_message = AssistantPromptMessage(content="", tool_calls=[]) + assistant_message = AssistantPromptMessage(content=response, tool_calls=[]) if tool_calls: assistant_message.tool_calls = [ AssistantPromptMessage.ToolCall( @@ -200,8 +200,6 @@ class FunctionCallAgentRunner(BaseAgentRunner): ) for tool_call in tool_calls ] - else: - assistant_message.content = response self._current_thoughts.append(assistant_message) diff --git a/api/core/model_runtime/entities/message_entities.py b/api/core/model_runtime/entities/message_entities.py index 3ac83b4c96..9e46d72893 100644 --- a/api/core/model_runtime/entities/message_entities.py +++ b/api/core/model_runtime/entities/message_entities.py @@ -251,10 +251,7 @@ class AssistantPromptMessage(PromptMessage): :return: True if prompt message is empty, False otherwise """ - if not super().is_empty() and not self.tool_calls: - return False - - return True + return super().is_empty() and not self.tool_calls class SystemPromptMessage(PromptMessage):