From 2171372246eb42b18e34293bf91839c67c696786 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:33:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20llm=5Ftool=20=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8=E8=BF=94=E5=9B=9E=E5=80=BC=E6=94=AF=E6=8C=81=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20mcp=20=E5=BA=93=E4=B8=AD=20tool=20=E7=9A=84?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E7=B1=BB=E5=9E=8B(mcp.type.CallTool?= =?UTF-8?q?Result)=20(#2507)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/process_stage/method/llm_request.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/astrbot/core/pipeline/process_stage/method/llm_request.py b/astrbot/core/pipeline/process_stage/method/llm_request.py index b65c58238..f3e7cd2df 100644 --- a/astrbot/core/pipeline/process_stage/method/llm_request.py +++ b/astrbot/core/pipeline/process_stage/method/llm_request.py @@ -171,11 +171,14 @@ class FunctionToolExecutor(BaseFunctionToolExecutor[AstrAgentContext]): ) async for resp in wrapper: if resp is not None: - text_content = mcp.types.TextContent( - type="text", - text=str(resp), - ) - yield mcp.types.CallToolResult(content=[text_content]) + if isinstance(resp, mcp.types.CallToolResult): + yield resp + else: + text_content = mcp.types.TextContent( + type="text", + text=str(resp), + ) + yield mcp.types.CallToolResult(content=[text_content]) else: # NOTE: Tool 在这里直接请求发送消息给用户 # TODO: 是否需要判断 event.get_result() 是否为空?