Stop API endpoint only works correctly for the first message #12384

Closed
opened 2026-02-21 19:07:09 -05:00 by yindo · 3 comments
Owner

Originally created by @zhangqm666 on GitHub (Mar 31, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using the Dify API’s /stop endpoint to interrupt streaming responses, I observe the following behavior:

First message in a session:

Calling /stop works correctly—the response is interrupted and the partial message is properly stored in the session history.

Subsequent messages in the same session:

Calling /stop appears to work (the stream stops), but when fetching the conversation history later, the interrupted message is blank instead of retaining the partially generated content.

This suggests the /stop endpoint may not correctly save partial responses to the session history after the first message.

Image

Image

Image

✔️ Expected Behavior

/stop should consistently save the partially generated response to session history, regardless of whether it’s the first or subsequent message.

Actual Behavior

Only the first interrupted message retains its content in history.

Subsequent interrupted messages appear blank when fetched later.

Originally created by @zhangqm666 on GitHub (Mar 31, 2025). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.0.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using the Dify API’s /stop endpoint to interrupt streaming responses, I observe the following behavior: First message in a session: Calling /stop works correctly—the response is interrupted and the partial message is properly stored in the session history. Subsequent messages in the same session: Calling /stop appears to work (the stream stops), but when fetching the conversation history later, the interrupted message is blank instead of retaining the partially generated content. This suggests the /stop endpoint may not correctly save partial responses to the session history after the first message. ![Image](https://github.com/user-attachments/assets/4158666a-fc93-49dc-81f1-5071fc1b205b) ![Image](https://github.com/user-attachments/assets/e75db20a-11b7-4257-a059-012897c067fc) ![Image](https://github.com/user-attachments/assets/a2d4dd25-6159-4033-be56-8cfecc46e419) ### ✔️ Expected Behavior /stop should consistently save the partially generated response to session history, regardless of whether it’s the first or subsequent message. ### ❌ Actual Behavior Only the first interrupted message retains its content in history. Subsequent interrupted messages appear blank when fetched later.
yindo added the 🐞 bug label 2026-02-21 19:07:09 -05:00
yindo closed this issue 2026-02-21 19:07:09 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 31, 2025):

Hello @zhangqm666! 👋 I'm here to help you with bug fixes, answering questions, and becoming a contributor.

The issue you're experiencing with the /stop endpoint in the Dify API, where only the first interrupted message retains its content in session history, might be related to how the API handles session management for subsequent messages. According to the information available, the Dify API differentiates between the first and subsequent messages in a session by using a conversation_id. For the first message, a new conversation_id is generated, and for subsequent messages, this ID must be included to maintain the conversation context [1][2].

The problem could be due to the way the API processes and stores partial messages for subsequent requests. It might be worth checking if the conversation_id is being correctly passed and handled in these cases. Additionally, reviewing the implementation of the /stop endpoint in the codebase might provide insights into why partial messages are not being saved for subsequent messages. The WorkflowTaskStopApi class in the api/controllers/console/app/workflow.py file is responsible for handling /stop requests, and it might be useful to examine how it interacts with session history [3].

If the issue persists, it may require further investigation into the specific logic used for storing partial responses in session history for subsequent messages.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 31, 2025): <!-- Greeting --> Hello @zhangqm666! 👋 I'm here to help you with bug fixes, answering questions, and becoming a contributor. <!-- Answer --> The issue you're experiencing with the `/stop` endpoint in the Dify API, where only the first interrupted message retains its content in session history, might be related to how the API handles session management for subsequent messages. According to the information available, the Dify API differentiates between the first and subsequent messages in a session by using a `conversation_id`. For the first message, a new `conversation_id` is generated, and for subsequent messages, this ID must be included to maintain the conversation context <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/application-publishing/developing-with-apis.md)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/14462)</sup>. The problem could be due to the way the API processes and stores partial messages for subsequent requests. It might be worth checking if the `conversation_id` is being correctly passed and handled in these cases. Additionally, reviewing the implementation of the `/stop` endpoint in the codebase might provide insights into why partial messages are not being saved for subsequent messages. The `WorkflowTaskStopApi` class in the `api/controllers/console/app/workflow.py` file is responsible for handling `/stop` requests, and it might be useful to examine how it interacts with session history <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/controllers/console/app/workflow.py)</sup>. If the issue persists, it may require further investigation into the specific logic used for storing partial responses in session history for subsequent messages. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8715f6bf-e04a-4663-9f77-821dd5a7203e?feedback_type=other)</sup>
Author
Owner

@icciccx commented on GitHub (Apr 12, 2025):

@dosu Hello, API can also reproduce this issue. When I deliberately force the conversation to respond with a longer answer, request the /:task_id/stop endpoint, and then input "hello", the new answer from dify will continue to respond based on the previous reply, I think this is a bug

@icciccx commented on GitHub (Apr 12, 2025): @dosu Hello, API can also reproduce this issue. When I deliberately force the conversation to respond with a longer answer, request the /:task_id/stop endpoint, and then input "hello", the new answer from dify will continue to respond based on the previous reply, I think this is a bug
Author
Owner

@icciccx commented on GitHub (Apr 12, 2025):

I browsed through the list of issues. There are several identical issues. The conversation stop /:task_id/stop endpoint does not work

@icciccx commented on GitHub (Apr 12, 2025): I browsed through the list of issues. There are several identical issues. The conversation stop /:task_id/stop endpoint does not work
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12384