fix: update message answer on completion after resume from pause - #38666
Open
EvanYao826 wants to merge 1 commit into
Open
fix: update message answer on completion after resume from pause#38666EvanYao826 wants to merge 1 commit into
EvanYao826 wants to merge 1 commit into
Conversation
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 langgenius#38614
Contributor
Pyrefly Type Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38614
Summary
When a ChatFlow workflow pauses (e.g., Human Input node) after a Question Classifier or Condition Branch node, the message is saved with
PAUSEDstatus and an empty answer. When the workflow resumes and completes,_handle_advanced_chat_message_end_eventskipped saving the final state because_message_saved_on_pausewasTrue, leaving the message stuck withPAUSEDstatus and no answer in the conversation.Root Cause
In
_handle_workflow_paused_event, the message is saved and its status is set toPAUSED. On completion,_handle_advanced_chat_message_end_eventguarded against double-saving withif not self._message_saved_on_pause, which skipped the update for resumed workflows. The final answer text was available in_task_state.answer, but never persisted.Fix
Removed the
_message_saved_on_pauseguard so_save_messageis always called on completion._save_messageuses_get_message(a SELECT by message_id) and updates the existing message in-place, so calling it again on completion overwrites the stalePAUSEDsnapshot with the correct answer andNORMALstatus. This is safe because_save_messageis idempotent — it only modifies the already-existing DB row.