The auto_generate_name param doesn't work correctly when r1 is used as the default model. #8565

Closed
opened 2026-02-21 18:26:21 -05:00 by yindo · 1 comment
Owner

Originally created by @yzztin on GitHub (Feb 24, 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

the latest code from main branch

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

  1. the conversation name is always New conversation when using r1 as default model
  2. core.llm_generator.llm_generator.LLMGenerator, the function generate_conversation_name() set max_tokens be 100 when invoke LLM to get conversation name
  3. If the LLM result have the content <think>, it seems 100 tokens is not enough.
  • my query is 你好,你是谁?
  • the result be like:
<think>\n好,我现在需要分析用户的输入,并将其分解为“主题”和“意图”,同时确定输出的语言类型。用户的问题是“你好,你是谁?”,这是一个典型的问候和询问身份的问题。\n\n首先,我观察到用户使用了纯中文,没有夹杂其他语言。因此,语言类型应该是“纯中文”。接下来,分析用户的意图,用户在问候之后询问了我的身份,这属于自我介绍或确认身份的意图。\n\n根据示例,当问题
  • as you can see, it didn't output the final result, so got the error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) when sept to the code json.loads(cleaned_answer)

✔️ Expected Behavior

  • get correct conversation name

Actual Behavior

  • the conversation name is always New conversation
Originally created by @yzztin on GitHub (Feb 24, 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 the latest code from `main` branch ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce 1. the conversation name is always `New conversation` when using `r1` as default model 2. `core.llm_generator.llm_generator.LLMGenerator`, the function `generate_conversation_name()` set `max_tokens` be `100` when invoke LLM to get conversation name 3. If the LLM result have the content `<think>`, it seems `100 tokens` is not enough. - my query is `你好,你是谁?` - the result be like: ``` <think>\n好,我现在需要分析用户的输入,并将其分解为“主题”和“意图”,同时确定输出的语言类型。用户的问题是“你好,你是谁?”,这是一个典型的问候和询问身份的问题。\n\n首先,我观察到用户使用了纯中文,没有夹杂其他语言。因此,语言类型应该是“纯中文”。接下来,分析用户的意图,用户在问候之后询问了我的身份,这属于自我介绍或确认身份的意图。\n\n根据示例,当问题 ``` - as you can see, it didn't output the final result, so got the error `json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)` when sept to the code `json.loads(cleaned_answer)` ### ✔️ Expected Behavior - get correct conversation name ### ❌ Actual Behavior - the conversation name is always `New conversation`
yindo added the 🐞 buggood first issue labels 2026-02-21 18:26:21 -05:00
yindo closed this issue 2026-02-21 18:26:21 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 24, 2025):

@yzztin Hello! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!

The issue you're encountering seems to be related to the generate_conversation_name() function in the LLMGenerator class, specifically when using the r1 model. The function sets max_tokens to 100, which might not be sufficient if the LLM's output includes extensive content like <think> tags, leading to incomplete responses and JSON decoding errors [1].

To address this, you might consider increasing the max_tokens parameter to allow the model to generate a more complete response. This could help ensure that the JSON object is fully formed and can be decoded without errors. Adjusting the max_tokens value could provide the necessary space for the model to complete its output, especially when handling complex or verbose responses.

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 (Feb 24, 2025): <!-- Greeting --> @yzztin Hello! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together! <!-- Answer --> The issue you're encountering seems to be related to the `generate_conversation_name()` function in the `LLMGenerator` class, specifically when using the `r1` model. The function sets `max_tokens` to 100, which might not be sufficient if the LLM's output includes extensive content like `<think>` tags, leading to incomplete responses and JSON decoding errors <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/llm_generator/llm_generator.py)</sup>. To address this, you might consider increasing the `max_tokens` parameter to allow the model to generate a more complete response. This could help ensure that the JSON object is fully formed and can be decoded without errors. Adjusting the `max_tokens` value could provide the necessary space for the model to complete its output, especially when handling complex or verbose responses. <!-- 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/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/25ab7131-9564-4aa1-8e02-aee7ea2bad4d?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8565