From dc52ec13ad956389e7808230794f48f101e95256 Mon Sep 17 00:00:00 2001 From: qing <1776177662@qq.com> Date: Tue, 4 Aug 2026 13:11:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(aibox):=20=E5=B7=A5=E5=85=B7=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E8=B6=85=E9=95=BF=E4=BB=85=E8=BF=94=E5=9B=9E=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E9=9A=94=E7=A6=BB=E5=90=84=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=89=A7=E8=A1=8C=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 工具结果超过 max_result_length 时不再保留截断内容,仅返回提示信息,避免超大结果污染 AI 上下文 - 每个任务/WebSocket 连接使用独立 SubprocessCommandExecutor,避免 cancel() 误杀其他任务/用户正在运行的子进程 --- aibox/aibox.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aibox/aibox.py b/aibox/aibox.py index e1e973e..bf99436 100644 --- a/aibox/aibox.py +++ b/aibox/aibox.py @@ -2861,7 +2861,8 @@ class TaskScheduler: history_manager=None, # 不加载历史对话上下文,任务隔离 memory_db=self.ai_manager.memory_db if self.ai_manager else None, memo_db=self.ai_manager.memo_db if self.ai_manager else None, - command_executor=self.ai_manager.command_executor if self.ai_manager else None, + # 每个任务使用独立的命令执行器,互不共享,避免 cancel() 误杀其他任务的子进程 + command_executor=SubprocessCommandExecutor(self.logger), prompt_manager=self.ai_manager.prompt_manager if self.ai_manager else None, skill_manager=self._get_shared_skill_manager() ) @@ -7030,10 +7031,10 @@ class DeepSeekChat: if not has_stream_output and output_callback and result: output_callback("line", result + "\n") - # 检查结果大小,如果超过阈值,截断返回提示信息 + # 检查结果大小,如果超过阈值,不保留截断内容,仅返回提示信息 if len(result) > MAX_RESULT_LENGTH: - truncated_note = f"\n\n⚠️ 结果已截断(原始 {len(result)} 字符,限制 {MAX_RESULT_LENGTH} 字符)。请使用更精确的查询获取所需信息。" - result = result[:MAX_RESULT_LENGTH] + truncated_note + truncated_note = f"⚠️ 工具调用结果长度超过 {MAX_RESULT_LENGTH} 字符,已丢弃。请使用更精确的查询获取所需信息。" + result = truncated_note if output_callback: output_callback("line", truncated_note + "\n") @@ -7691,7 +7692,8 @@ class WebSocketHandler: history_manager=None, # 不加载共享历史上下文,避免多用户历史相互污染 memory_db=self.ai_manager.memory_db, memo_db=self.ai_manager.memo_db, - command_executor=self.ai_manager.command_executor, + # 每个连接使用独立的命令执行器,互不共享,避免 cancel() 误杀其他用户/任务正在运行的子进程 + command_executor=SubprocessCommandExecutor(self.logger), prompt_manager=self.ai_manager.prompt_manager, skill_manager=self._get_shared_skill_manager() )