From 7c406a548cd10433545e082c6c11a1668dd947d1 Mon Sep 17 00:00:00 2001 From: Wxysnx <625024108@qq.com> Date: Fri, 20 Jun 2025 14:49:47 +0800 Subject: [PATCH] fix Issues#897 --- swarms/structs/agent.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index dce3c2c2..934714d8 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -1051,7 +1051,19 @@ class Agent: # # Convert to a str if the response is not a str # if self.mcp_url is None or self.tools is None: - response = self.parse_llm_output(response) + # response = self.parse_llm_output(response) + # Check if response is empty + if (response is None or + (isinstance(response, dict) and not response) or + (isinstance(response, str) and not response.strip()) or + (isinstance(response, list) and not response) or + (hasattr(response, "__len__") and len(response) == 0)): + + # response is empty, assign prompt information + response = {"message": "The LLM return value is empty"} + else: + # response is not empty, perform normal parsing + response = self.parse_llm_output(response) self.short_memory.add( role=self.agent_name,