From 937f0b7f323e41d0c86919d7df5058a9ba18a1d5 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 15 Jan 2026 00:48:50 +0800 Subject: [PATCH] fix: handle empty output case in PythonTool execution --- astrbot/core/sandbox/tools/python.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/astrbot/core/sandbox/tools/python.py b/astrbot/core/sandbox/tools/python.py index fe01dc50a..791a7e691 100644 --- a/astrbot/core/sandbox/tools/python.py +++ b/astrbot/core/sandbox/tools/python.py @@ -62,6 +62,11 @@ class PythonTool(FunctionTool): if text: resp.content.append(mcp.types.TextContent(type="text", text=text)) + if not resp.content: + resp.content.append( + mcp.types.TextContent(type="text", text="No output.") + ) + return resp except Exception as e: