From 12c7aeb2596f15c6babceae1150c2e1400e90f57 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Sat, 15 Nov 2025 12:52:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BF=AE=E5=A4=8D=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E7=94=A8=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=92=8C=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改进工具调用状态的判断逻辑,使用status字段替代tool_call_result 前端增加错误状态显示,包括错误信息展示 后端确保tool_output为空时返回空字符串而非null --- docs/latest/changelog/roadmap.md | 2 +- server/routers/chat_router.py | 5 +++-- web/src/components/AgentMessageComponent.vue | 12 ++++++++---- web/src/utils/chatExporter.js | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/latest/changelog/roadmap.md b/docs/latest/changelog/roadmap.md index 3b305cf3..f9f8d28b 100644 --- a/docs/latest/changelog/roadmap.md +++ b/docs/latest/changelog/roadmap.md @@ -17,7 +17,6 @@ ### Bugs - 部分异常状态下,智能体的模型名称出现重叠[#279](https://github.com/xerrors/Yuxi-Know/issues/279) - DeepSeek 官方接口适配会出现问题 -- 当前版本如果调用结果为空的时候,工具调用状态会一直处于调用状态,尽管调用是成功的 - 目前的知识库的图片存在公开访问风险 ### 新增 @@ -33,6 +32,7 @@ ### 修复 - 修复重排序模型实际未生效的问题 - 修复消息中断后消息消失的问题,并改善异常效果 +- 修复当前版本如果调用结果为空的时候,工具调用状态会一直处于调用状态,尽管调用是成功的 ## v0.3 diff --git a/server/routers/chat_router.py b/server/routers/chat_router.py index 7759f51b..24ecc964 100644 --- a/server/routers/chat_router.py +++ b/server/routers/chat_router.py @@ -863,10 +863,11 @@ async def get_agent_history( { "id": str(tc.id), "name": tc.tool_name, - "function": {"name": tc.tool_name}, # Frontend compatibility + "function": {"name": tc.tool_name}, "args": tc.tool_input or {}, - "tool_call_result": {"content": tc.tool_output} if tc.tool_output else None, + "tool_call_result": {"content": (tc.tool_output or "")} if tc.status == "success" else None, "status": tc.status, + "error_message": tc.error_message, } for tc in msg.tool_calls ] diff --git a/web/src/components/AgentMessageComponent.vue b/web/src/components/AgentMessageComponent.vue index d046323b..42adc209 100644 --- a/web/src/components/AgentMessageComponent.vue +++ b/web/src/components/AgentMessageComponent.vue @@ -43,14 +43,18 @@
- + +   工具 {{ getToolNameByToolCall(toolCall) }} 执行完成 + + +   工具 {{ getToolNameByToolCall(toolCall) }} 执行失败 + ({{ toolCall.error_message }}) + +   正在调用工具: {{ getToolNameByToolCall(toolCall) }} - -   工具 {{ getToolNameByToolCall(toolCall) }} 执行完成 -
diff --git a/web/src/utils/chatExporter.js b/web/src/utils/chatExporter.js index b1574183..20e2d1cd 100644 --- a/web/src/utils/chatExporter.js +++ b/web/src/utils/chatExporter.js @@ -242,7 +242,7 @@ export class ChatExporter { const argsSource = toolCall?.args ?? toolCall?.function?.arguments; const args = this.stringifyToolArgs(argsSource); const result = this.normalizeToolResult(toolCall?.tool_call_result?.content); - const isFinished = Boolean(toolCall?.tool_call_result); + const isFinished = toolCall?.status === 'success'; const stateClass = isFinished ? 'done' : 'pending'; const stateLabel = isFinished ? '已完成' : '执行中';