From b72090f0242233624715c2d3b5358e9e95a52045 Mon Sep 17 00:00:00 2001 From: tt-P607 <68868379+tt-P607@users.noreply.github.com> Date: Sat, 25 Oct 2025 03:29:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BF=AE=E5=A4=8D=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E6=89=A7=E8=A1=8C=E5=BC=82=E5=B8=B8=E6=97=B6=20is=5Fr?= =?UTF-8?q?eplying=20=E7=8A=B6=E6=80=81=E6=9C=AA=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `execute_action` 方法中引入 `try...finally` 结构,以确保无论动作执行成功与否,`is_replying` 状态最终都能被可靠地重置为 `False`。 此更改解决了在动作执行期间发生意外错误时,聊天流可能被永久锁定在“正在回复”状态的问题,从而提高了系统的健壮性。 --- src/chat/planner_actions/action_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/chat/planner_actions/action_manager.py b/src/chat/planner_actions/action_manager.py index e7ff21ad4..90d2b265e 100644 --- a/src/chat/planner_actions/action_manager.py +++ b/src/chat/planner_actions/action_manager.py @@ -165,6 +165,7 @@ class ChatterActionManager: 执行结果 """ + chat_stream = None try: logger.debug(f"🎯 [ActionManager] execute_action接收到 target_message: {target_message}") # 通过chat_id获取chat_stream @@ -180,6 +181,9 @@ class ChatterActionManager: "error": "chat_stream not found", } + # 设置正在回复的状态 + chat_stream.context_manager.context.is_replying = True + if action_name == "no_action": return {"action_type": "no_action", "success": True, "reply_text": "", "command": ""} @@ -205,7 +209,7 @@ class ChatterActionManager: action_build_into_prompt=False, action_prompt_display=reason, action_done=True, - thinking_id=thinking_id, + thinking_id=thinking_id or "", action_data={"reason": reason}, action_name="no_reply", ) @@ -298,6 +302,10 @@ class ChatterActionManager: "loop_info": None, "error": str(e), } + finally: + # 确保重置正在回复的状态 + if chat_stream: + chat_stream.context_manager.context.is_replying = False async def _record_action_to_message(self, chat_stream, action_name, target_message, action_data): """