dify icon indicating copy to clipboard operation
dify copied to clipboard

Conversation Not Exists

Open imaxwen opened this issue 1 year ago • 3 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Call dify's chat api /chat-messages with an empty conversation_id first time:

my application log:

bot-api  | INFO:APIClient:Request dify app with: 
bot-api  | {
bot-api  |   "inputs": {
bot-api  |     "session_type": "private",
bot-api  |     "has_group": "no"
bot-api  |   },
bot-api  |   "query": "hi there~",
bot-api  |   "response_mode": "blocking",
bot-api  |   "conversation_id": null,
bot-api  |   "user": "TestUser_5728",
bot-api  |   "files": null
bot-api  | }

Dify's chat api response:

bot-api  |  {
  "event": "message",
  "task_id": "e0655075-f1a4-4e9b-ac2d-d182206d11bc",
  "id": "f13817ad-e923-4c6b-acbb-b0fad4ef54ed",
  "message_id": "f13817ad-e923-4c6b-acbb-b0fad4ef54ed",
  "conversation_id": "857422d9-b321-408a-95ea-b03436122c1e",
  "mode": "advanced-chat",
  "answer": "Hi, How can I assist you tody?",
  "metadata": {
    "usage": {
      "prompt_tokens": 1368,
      "prompt_unit_price": "0.0",
      "prompt_price_unit": "0.0",
      "prompt_price": "0.0",
      "completion_tokens": 60,
      "completion_unit_price": "0.0",
      "completion_price_unit": "0.0",
      "completion_price": "0.0",
      "total_tokens": 1428,
      "total_price": "0.0",
      "currency": "USD",
      "latency": 10.894286551512778
    }
  },
  "created_at": 1740985593
}

Then I cached this conversation_id into my redis instance to associate the user_id in my system with dify's conversation_id

  1. Then Another user message from my chat app comes. I continue the conversation with the conversation_id from the response.(IMPORTANT: The intervals between the two calls are very short, around 500ms. )

I got conversation_id above from my redis instance.

and the request log:

bot-api  | INFO:APIClient:Request dify app with: 
bot-api  | {
bot-api  |   "inputs": {
bot-api  |     "session_type": "private",
bot-api  |     "has_group": "no"
bot-api  |   },
bot-api  |   "query": "Please introduce yourself",
bot-api  |   "response_mode": "blocking",
bot-api  |   "conversation_id": "857422d9-b321-408a-95ea-b03436122c1e",
bot-api  |   "user": "TestUser_5728",
bot-api  |   "files": null
bot-api  | }
  1. Dify api response an Conversation Not Exists error:
bot-api  | INFO:APIClient:Dify app Response: 
bot-api  | {'code': 'not_found', 'message': 'Conversation Not Exists.', 'status': 404}

My assumption: It is possible that dify uses uuid as conversation_id. During the first session, the conversation_id returned in the response was not actually stored in dify's database. In a very short interval, I used this conversation_id to initiate subsequent sessions, which led to this 404 error.

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

imaxwen avatar Mar 04 '25 09:03 imaxwen

The "Conversation Not Exists" error you're encountering is likely due to the way the Dify API handles conversation IDs. When you make the initial request without a conversation_id, the server generates one and returns it in the response. This ID should be used for subsequent messages to maintain the conversation continuity.

Here are some relevant points and similar issues that might help:

  1. Use the Generated conversation_id: Ensure that you are using the conversation_id provided by the server in the response of your initial request. This ID is necessary for continuing the conversation in subsequent requests [1].

  2. Timing Considerations: The short interval between requests (500ms) might be causing issues if the conversation ID is not fully registered or propagated in the system. Consider adding a slight delay or checking if the conversation ID is valid before proceeding with the next request.

  3. Similar Issues: There have been similar discussions and issues reported:

  4. Version Updates: Consider updating to a newer version of Dify if available, as some issues related to conversation persistence have been addressed in later updates [4].

By ensuring the correct use of the conversation_id and considering the timing of your requests, you should be able to resolve the "Conversation Not Exists" error.

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] avatar Mar 04 '25 09:03 dosubot[bot]

1.0.0 has the same problem too

chowyu12 avatar Mar 06 '25 09:03 chowyu12

Perhaps an API for actively creating sessions can be developed, such as using the user parameter to actively create a session and returning a conversation_id for subsequent sessions.

imaxwen avatar Mar 07 '25 05:03 imaxwen

Having same issue - even though I have verified that the conversation exists, and tried making a brand new conversation just to see if they somehow get archived, I always get:

{"code": "not_found", "message": "Conversation Not Exists.", "status": 404}

This is preventing us for doing asynchronous communication back to the conversation which is a major issue.

benjamin-mogensen avatar May 01 '25 14:05 benjamin-mogensen

Having same issue - even though I have verified that the conversation exists, and tried making a brand new conversation just to see if they somehow get archived, I always get:

{"code": "not_found", "message": "Conversation Not Exists.", "status": 404} This is preventing us for doing asynchronous communication back to the conversation which is a major issue.

@crazywoola is this to be fixed or will not be fixed?

benjamin-mogensen avatar May 06 '25 14:05 benjamin-mogensen

网页使用对话的时候,如果出现这个报错,点击网页右上角的图标重置对话就行。

sherry-kaikai avatar Sep 23 '25 07:09 sherry-kaikai