[bedrock] Error: ValidationException: A conversation must start with a user message. Try again with a conversation that starts with a user message. #7507

Closed
opened 2026-02-21 18:20:57 -05:00 by yindo · 4 comments
Owner

Originally created by @luckylhb90 on GitHub (Jan 3, 2025).

Originally assigned to: @crazywoola on GitHub.

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

0.10.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. When we use sonnet3.5 with memory enabled, this error is always reported when we call it.

[bedrock] Error: ValidationException: A conversation must start with a user message. Try again with a conversation that starts with a user message.

image
  1. I analyzed the code and guessed that it might have something to do with checking tokens here. For the other models, I didn't think there was a problem, but for sonnet, if we removed a prompt, it would cause this error.
    image

  2. I try to modify the configuration of the model, but again I get input token overrun issues.
    context_size: 20000000

Is there any relevant experience you can provide for our reference?

✔️ Expected Behavior

Even if the memory function is enabled, users will not be affected.

Actual Behavior

Always get the following error:

image image
Originally created by @luckylhb90 on GitHub (Jan 3, 2025). Originally assigned to: @crazywoola on GitHub. ### 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 0.10.2 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. When we use sonnet3.5 with memory enabled, this error is always reported when we call it. [bedrock] Error: ValidationException: A conversation must start with a user message. Try again with a conversation that starts with a user message. <img width="784" alt="image" src="https://github.com/user-attachments/assets/664730f4-729a-416f-9830-95e82995ca12" /> 2. I analyzed the code and guessed that it might have something to do with checking tokens here. For the other models, I didn't think there was a problem, but for sonnet, if we removed a prompt, it would cause this error. <img width="1096" alt="image" src="https://github.com/user-attachments/assets/11bde704-5654-41d0-8214-9d699a19add0" /> 3. I try to modify the configuration of the model, but again I get input token overrun issues. context_size: 20000000 Is there any relevant experience you can provide for our reference? ### ✔️ Expected Behavior Even if the memory function is enabled, users will not be affected. ### ❌ Actual Behavior Always get the following error: <img width="784" alt="image" src="https://github.com/user-attachments/assets/664730f4-729a-416f-9830-95e82995ca12" /> <img width="680" alt="image" src="https://github.com/user-attachments/assets/22825902-54a9-4a49-abcd-1f779b841f7f" />
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 18:20:57 -05:00
yindo closed this issue 2026-02-21 18:20:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 3, 2025):

I found a similar unsolved discussion that might be relevant to your issue: Error using large language model [1].

Regarding your issue, it seems that the error "A conversation must start with a user message" is related to how the conversation is initiated in the Dify platform. To start a conversation with a user message, you need to ensure that the initial message in the conversation is from the user. This can be done using the create_chat_message method from the ChatClient class, where you specify the query as the user's message and leave the conversation_id empty to start a new conversation [2].

Additionally, the token_buffer_memory.py script is responsible for managing the conversation history while respecting token limits. It retrieves and formats past messages, ensuring that the total number of tokens does not exceed a specified limit. If the token count exceeds the limit, it prunes messages from the start of the list [3].

For the 'Claude 3.5 Sonnet' model, the default max_tokens is set to 8192. If you're encountering input token overrun issues, you might need to adjust this parameter to prevent exceeding the token limit [4].

Ensure that your initial user message is correctly formatted and that the token limits are configured appropriately to avoid these errors.

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Jan 3, 2025): <!-- Answer --> I found a similar unsolved discussion that might be relevant to your issue: [Error using large language model](https://github.com/langgenius/dify/discussions/10144) <sup>[[1]](https://github.com/langgenius/dify/discussions/10144)</sup>. Regarding your issue, it seems that the error "A conversation must start with a user message" is related to how the conversation is initiated in the Dify platform. To start a conversation with a user message, you need to ensure that the initial message in the conversation is from the user. This can be done using the `create_chat_message` method from the `ChatClient` class, where you specify the `query` as the user's message and leave the `conversation_id` empty to start a new conversation <sup>[[2]](https://github.com/langgenius/dify/blob/main/sdks/php-client/dify-client.php)</sup>. Additionally, the `token_buffer_memory.py` script is responsible for managing the conversation history while respecting token limits. It retrieves and formats past messages, ensuring that the total number of tokens does not exceed a specified limit. If the token count exceeds the limit, it prunes messages from the start of the list <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/memory/token_buffer_memory.py)</sup>. For the 'Claude 3.5 Sonnet' model, the default `max_tokens` is set to 8192. If you're encountering input token overrun issues, you might need to adjust this parameter to prevent exceeding the token limit <sup>[[4]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/vertex_ai/llm/anthropic.claude-3.5-sonnet.yaml)</sup>. Ensure that your initial user message is correctly formatted and that the token limits are configured appropriately to avoid these errors. <!-- 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/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/a1e219af-7a15-4b75-9d17-5a7b2b1b137c?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Jan 3, 2025):

Can you try it in the latest version?

@crazywoola commented on GitHub (Jan 3, 2025): Can you try it in the latest version?
Author
Owner

@luckylhb90 commented on GitHub (Jan 3, 2025):

Can you try it in the latest version?

We're upgrading, too. Let me test it.

@luckylhb90 commented on GitHub (Jan 3, 2025): > Can you try it in the latest version? We're upgrading, too. Let me test it.
Author
Owner

@crazywoola commented on GitHub (Jan 7, 2025):

Did you fix it?

@crazywoola commented on GitHub (Jan 7, 2025): Did you fix it?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7507