fix: add ops trace task when chat message generation fails#39236
Open
EvanYao826 wants to merge 2 commits into
Open
fix: add ops trace task when chat message generation fails#39236EvanYao826 wants to merge 2 commits into
EvanYao826 wants to merge 2 commits into
Conversation
When a workflow pauses (e.g. Human Input node), _handle_workflow_paused_event saves the message with PAUSED status. On completion after resume, _handle_advanced_chat_message_end_event skipped saving because _message_saved_on_pause was True, leaving the message stuck with PAUSED status and empty answer. The fix removes the _message_saved_on_pause guard so _save_message is always called on completion. _save_message does SELECT + UPDATE by message_id, so it is idempotent — calling it multiple times is safe. Inside _save_message, the message status is already transitioned from PAUSED to NORMAL. Fixes langgenius#38824
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.
Summary
When a chat message generation fails (e.g., LLM provider returns an error), the ops trace task is not sent because the
QueueErrorEventhandler breaks out of the event loop before reaching_save_message, which is the only place where the trace task is added.This fix adds the trace task directly in the
QueueErrorEventhandler, ensuring that even when LLM generation fails, the monitoring system can still capture the error event.Root Cause
In
EasyUIBasedGenerateTaskPipeline._process_stream_response:QueueErrorEventhandler: handles error, breaks → no trace taskQueueStopEvent | QueueMessageEndEventhandler: calls_save_message→ adds trace task (never reached on error)Fix
Added the same
trace_manager.add_trace_task()call in theQueueErrorEventhandler (after session commit, before yield/break), matching the pattern already used in_save_message.Related Issue
Closes #39128