Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: preserve inline image for chatflow messages (#37455)
Yunlu Wen4b15b0e6a6f3
diff --git a/api/core/app/apps/advanced_chat/generate_task_pipeline.py b/api/core/app/apps/advanced_chat/generate_task_pipeline.pyindex 6f8117ee590..d8ca19b5fc3 100644--- a/api/core/app/apps/advanced_chat/generate_task_pipeline.py+++ b/api/core/app/apps/advanced_chat/generate_task_pipeline.py@@ -1,6 +1,5 @@import jsonimport logging-import reimport timefrom collections.abc import Callable, Generator, Mappingfrom contextlib import contextmanager@@ -1010,11 +1009,7 @@ class AdvancedChatAppGenerateTaskPipeline(GraphRuntimeStateSupport):if message.status == MessageStatus.PAUSED:message.status = MessageStatus.NORMAL- # If there are assistant files, remove markdown image links from answeranswer_text = self._task_state.answer- if self._recorded_files:- # Remove markdown image links since we're storing files separately- answer_text = re.sub(r"!\[.*?\]\(.*?\)", "", answer_text).strip()message.answer = answer_textmessage.updated_at = naive_utc_now()diff --git a/api/tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py b/api/tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.pyindex 9726c939e94..b75f6d44943 100644--- a/api/tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py+++ b/api/tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py@@ -562,7 +562,7 @@ class TestAdvancedChatGenerateTaskPipeline:assert list(pipeline._handle_human_input_form_timeout_event(timeout_event)) == ["timeout"]assert persisted == ["saved"]- def test_save_message_strips_markdown_and_sets_usage(self):+ def test_save_message_preserves_full_answer_and_sets_usage(self):pipeline = _make_pipeline()pipeline._recorded_files = [{@@ -572,7 +572,8 @@ class TestAdvancedChatGenerateTaskPipeline:"related_id": "file-id",}]- pipeline._task_state.answer = " hello"+ # The answer is stored verbatim; markdown image links are never stripped.+ pipeline._task_state.answer = " hello "pipeline._task_state.is_streaming_response = Truepipeline._task_state.first_token_time = pipeline._base_task_pipeline.start_at + 0.1pipeline._task_state.last_token_time = pipeline._base_task_pipeline.start_at + 0.2@@ -614,7 +615,7 @@ class TestAdvancedChatGenerateTaskPipeline:pipeline._save_message(session=_Session(), graph_runtime_state=graph_runtime_state)assert message.status == MessageStatus.NORMAL- assert message.answer == "hello"+ assert message.answer == " hello "assert message.message_metadatadef test_handle_stop_event_saves_message_for_moderation(self, monkeypatch: pytest.MonkeyPatch):