Skip to content

fix: add ops trace task when chat message generation fails#39236

Open
EvanYao826 wants to merge 2 commits into
langgenius:mainfrom
EvanYao826:fix/39128-ops-trace-on-llm-error
Open

fix: add ops trace task when chat message generation fails#39236
EvanYao826 wants to merge 2 commits into
langgenius:mainfrom
EvanYao826:fix/39128-ops-trace-on-llm-error

Conversation

@EvanYao826

Copy link
Copy Markdown
Contributor

Summary

When a chat message generation fails (e.g., LLM provider returns an error), the ops trace task is not sent because the QueueErrorEvent handler 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 QueueErrorEvent handler, ensuring that even when LLM generation fails, the monitoring system can still capture the error event.

Root Cause

In EasyUIBasedGenerateTaskPipeline._process_stream_response:

  • QueueErrorEvent handler: handles error, breaks → no trace task
  • QueueStopEvent | QueueMessageEndEvent handler: calls _save_message → adds trace task (never reached on error)

Fix

Added the same trace_manager.add_trace_task() call in the QueueErrorEvent handler (after session commit, before yield/break), matching the pattern already used in _save_message.

Related Issue

Closes #39128

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
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing ops trace task when chat message generation fails

1 participant