Stop message replies through the dify API, and the already replied messages will not be saved. But what stopped through testing is normal #21825

Closed
opened 2026-02-21 20:14:29 -05:00 by yindo · 1 comment
Owner

Originally created by @fanpocha on GitHub (Jan 21, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Stop message replies through the dify API, and the already replied messages will not be saved. But what stopped through testing is normal

✔️ Expected Behavior

Stop message replies through the dify API, and the already replied messages will not be saved. But what stopped through testing is normal

Actual Behavior

No response

Originally created by @fanpocha on GitHub (Jan 21, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Stop message replies through the dify API, and the already replied messages will not be saved. But what stopped through testing is normal ### ✔️ Expected Behavior Stop message replies through the dify API, and the already replied messages will not be saved. But what stopped through testing is normal ### ❌ Actual Behavior _No response_
yindo added the 🐞 bugoutdated labels 2026-02-21 20:14:29 -05:00
yindo closed this issue 2026-02-21 20:14:29 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 21, 2026):

Hi @fanpocha! I'm Dosu and I’m helping the dify team.

This is a known issue in Dify 1.8.1: when you stop message replies via the API, already replied (partial) messages sometimes aren't saved, while stopping through the UI/testing works as expected. The root cause is a difference in how message persistence is triggered—API stops rely on event-driven logic that can miss saving the message if the stop event isn't handled in time, or if there's a race condition in the event pipeline. In contrast, the UI/testing flow updates and saves messages directly before the stop event completes, making it more reliable for persistence.

There are also known bugs where only the first interrupted message in a session is saved, and subsequent interrupted messages appear blank in history. This is likely related to how the API manages session state and conversation_id for subsequent messages, and possibly to race conditions in the message/event pipeline. If you need a workaround, ensure that conversation_id is always correctly passed for each message, and consider adding logging or synchronization in the pipeline to make sure all message save events are processed before finalizing the message. For more technical details and discussion, see this issue and this analysis of the event pipeline.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 21, 2026): <!-- Greeting --> Hi @fanpocha! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This is a known issue in Dify 1.8.1: when you stop message replies via the API, already replied (partial) messages sometimes aren't saved, while stopping through the UI/testing works as expected. The root cause is a difference in how message persistence is triggered—API stops rely on event-driven logic that can miss saving the message if the stop event isn't handled in time, or if there's a race condition in the event pipeline. In contrast, the UI/testing flow updates and saves messages directly before the stop event completes, making it more reliable for persistence. There are also known bugs where only the first interrupted message in a session is saved, and subsequent interrupted messages appear blank in history. This is likely related to how the API manages session state and conversation_id for subsequent messages, and possibly to race conditions in the message/event pipeline. If you need a workaround, ensure that conversation_id is always correctly passed for each message, and consider adding logging or synchronization in the pipeline to make sure all message save events are processed before finalizing the message. For more technical details and discussion, see [this issue](https://github.com/langgenius/dify/issues/17191) and [this analysis of the event pipeline](https://github.com/langgenius/dify/issues/29033). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5a108990-273a-436a-ac0c-0353bc995d3a?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20in%20Dify%201.8.1%3A%20when%20you%20stop%20message%20replies%20via%20the%20API%2C%20already%20replied%20%28partial%29%20messages%20sometimes%20aren%27t%20saved%2C%20while%20stopping%20through%20the%20UI/testing%20works%20as%20expected.%20The%20root%20cause%20is%20a%20difference%20in%20how%20message%20persistence%20is%20triggered%E2%80%94API%20stops%20rely%20on%20event-driven%20logic%20that%20can%20miss%20saving%20the%20message%20if%20the%20stop%20event%20isn%27t%20handled%20in%20time%2C%20or%20if%20there%27s%20a%20race%20condition%20in%20the%20event%20pipeline.%20In%20contrast%2C%20the%20UI/testing%20flow%20updates%20and%20saves%20messages%20directly%20before%20the%20stop%20event%20completes%2C%20making%20it%20more%20reliable%20for%20persistence.%0A%0AThere%20are%20also%20known%20bugs%20where%20only%20the%20first%20interrupted%20message%20in%20a%20session%20is%20saved%2C%20and%20subsequent%20interrupted%20messages%20appear%20blank%20in%20history.%20This%20is%20likely%20related%20to%20how%20the%20API%20manages%20session%20state%20and%20conversation_id%20for%20subsequent%20messages%2C%20and%20possibly%20to%20race%20conditions%20in%20the%20message/event%20pipeline.%20If%20you%20need%20a%20workaround%2C%20ensure%20that%20conversation_id%20is%20always%20correctly%20passed%20for%20each%20message%2C%20and%20consider%20adding%20logging%20or%20synchronization%20in%20the%20pipeline%20to%20make%20sure%20all%20message%20save%20events%20are%20processed%20before%20finalizing%20the%20message.%20For%20more%20technical%20details%20and%20discussion%2C%20see%20%5Bthis%20issue%5D%28https%3A//github.com/langgenius/dify/issues/17191%29%20and%20%5Bthis%20analysis%20of%20the%20event%20pipeline%5D%28https%3A//github.com/langgenius/dify/issues/29033%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31370)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21825