fix(aibox/botops): 修复重复输出问题

1. 服务端:is_continuation(工具调用后递归继续)时不再重复发送
   "思考中"提示和reasoning_start信号,避免多轮工具调用时侧栏
   出现多条冗余"思考中"消息
2. BotOps:line消息过滤前缀从5个扩展到9个,过滤掉"分析工具结果"
   "需要调用工具"等被后续具体信息覆盖的过渡提示
3. BotOps:移除危险的fallback分支(未知消息类型直接append到AI
   聊天区),改为写入侧栏日志,防止非AI内容污染回复
This commit is contained in:
qing committed 2026-08-01 20:53:40 +08:00
1 parent f701730016
commit 27ab50ae68
2 files changed
+14 -5

No files matched your search

+11 -4
View File
@@ -186,10 +186,16 @@ class BotOpsApp(App):
stripped = content.strip() stripped = content.strip()
if not stripped: if not stripped:
pass pass
elif stripped.startswith(("💬 助手", "💬 Assistant", "🤔 思考中", "🤔 Thinking", "🤔 深度思考中")): elif stripped.startswith((
pass # 助手前缀 / 思考提示:聊天区已有对应区域,无需展示 "💬 助手", "💬 Assistant", # 助手前缀(聊天区已有对应区域)
"🤔 思考中", "🤔 Thinking", # 思考提示(聊天区已有思考区域)
"🤔 深度思考中",
"🤔 分析工具结果", "🤔 Analyzing", # 工具分析提示(后续有具体工具输出,此为冗余)
"🔧 需要调用工具", "🔧 Need to call",# 工具调用前置提示(后续有"调用工具: xxx"具体提示)
)):
pass # 冗余/有替代展示的提示行,过滤避免重复
else: else:
# 🔧 调用工具 / 工具输出 / 🤔 分析工具结果 等 → 任务侧栏 # 🔧 调用工具: xxx / 工具输出 / 用户中断提示等 → 任务侧栏
self.tasks.write(stripped) self.tasks.write(stripped)
elif t == "complete": elif t == "complete":
# complete 携带完整全文,用于对齐已显示内容 # complete 携带完整全文,用于对齐已显示内容
@@ -244,7 +250,8 @@ class BotOpsApp(App):
elif t == "notification": elif t == "notification":
await self.notify_system(f"🔔 {content}") await self.notify_system(f"🔔 {content}")
elif content: elif content:
await self.chat.append_ai(content) # 未知消息类型不追加到AI聊天区(避免非AI内容污染回复),仅记入侧栏日志
self.tasks.write(f"[未知消息 type={t}] {str(content)[:200]}")
# ── 连接状态回调 ────────────────────────────────────────────────────── # ── 连接状态回调 ──────────────────────────────────────────────────────
async def _on_ws_state(self, state: str, detail: str): async def _on_ws_state(self, state: str, detail: str):
+3 -1
View File
@@ -7267,7 +7267,9 @@ class DeepSeekChat:
payload["tool_choice"] = "auto" payload["tool_choice"] = "auto"
current_time = datetime.now().strftime("%H:%M:%S") current_time = datetime.now().strftime("%H:%M:%S")
if output_callback: if output_callback and not is_continuation:
# 工具调用后的递归继续(is_continuation=True)时不重复发送"思考中"提示,
# 因为前端已处于活跃AI状态,重复提示会导致冗余/重复输出
output_callback("line", f"\n{i18n.get('thinking', current_time)}\n") output_callback("line", f"\n{i18n.get('thinking', current_time)}\n")
if constants.REASONING_ENABLED: if constants.REASONING_ENABLED:
output_callback("reasoning_start", "🤔 思考中...") output_callback("reasoning_start", "🤔 思考中...")