From eefa3f2f004f0d7f18e1bdae95ebadf437c7ea89 Mon Sep 17 00:00:00 2001 From: Gao Jinzhe <2968474907@qq.com> Date: Wed, 7 Jan 2026 12:48:13 +0800 Subject: [PATCH] fix: conversation was still saved to the context after `stop_event` (#4345) --- .../method/agent_sub_stages/internal.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py index 69bd04314..62ccddbf9 100644 --- a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +++ b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py @@ -522,13 +522,15 @@ class InternalAgentSubStage(Stage): ): yield - await self._save_to_history( - event, - req, - agent_runner.get_final_llm_resp(), - agent_runner.run_context.messages, - agent_runner.stats, - ) + # 检查事件是否被停止,如果被停止则不保存历史记录 + if not event.is_stopped(): + await self._save_to_history( + event, + req, + agent_runner.get_final_llm_resp(), + agent_runner.run_context.messages, + agent_runner.stats, + ) # 异步处理 WebChat 特殊情况 if event.get_platform_name() == "webchat":