From 2551ee2d8bc6b6813b0f91b7feba048bbd245f9b Mon Sep 17 00:00:00 2001 From: EvanYao826 <2869018789@qq.com> Date: Fri, 10 Jul 2026 20:47:22 +0800 Subject: [PATCH] fix: update message answer on completion after resume from pause When a ChatFlow workflow pauses (e.g., Human Input node) after a Question Classifier or Condition Branch, the message is saved with PAUSED status and empty answer. On resume and completion, _handle_advanced_chat_message_ end_event skipped saving the final state because _message_saved_on_pause was True, leaving the message stuck with PAUSED status and no answer. The fix removes the guard so _save_message is always called on completion. _save_message updates the existing message in-place (it does a SELECT by message_id), overwriting the stale PAUSED snapshot with the final answer and NORMAL status. Fixes #38614 --- .../app/apps/advanced_chat/generate_task_pipeline.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/core/app/apps/advanced_chat/generate_task_pipeline.py b/api/core/app/apps/advanced_chat/generate_task_pipeline.py index c0d6952871e..68734c84616 100644 --- a/api/core/app/apps/advanced_chat/generate_task_pipeline.py +++ b/api/core/app/apps/advanced_chat/generate_task_pipeline.py @@ -807,10 +807,11 @@ class AdvancedChatAppGenerateTaskPipeline(GraphRuntimeStateSupport): reason=QueueMessageReplaceEvent.MessageReplaceReason.OUTPUT_MODERATION, ) - # Save message unless it has already been persisted on pause. - if not self._message_saved_on_pause: - with self._database_session() as session: - self._save_message(session=session, graph_runtime_state=resolved_state) + # Always save the final message state, even if it was already + # persisted on pause. The previous snapshot (PAUSED status, empty + # answer) must be replaced with the completed answer. + with self._database_session() as session: + self._save_message(session=session, graph_runtime_state=resolved_state) yield self._message_end_to_stream_response()