The content of the prompt generator is incomplete #5396

Closed
opened 2026-02-21 18:10:47 -05:00 by yindo · 11 comments
Owner

Originally created by @GeorgeGalway on GitHub (Sep 4, 2024).

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.6.7~0.7.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

image
When there are too many commands, the content returned by the prompt generator is incomplete. This issue has been tested and reproduced multiple times.

✔️ Expected Behavior

I expect the prompt generator to return complete content.

Actual Behavior

The content returned by the prompt generator is not exactly what I want, especially the second half, where the examples are incomplete. This leads to poor output quality.

Originally created by @GeorgeGalway on GitHub (Sep 4, 2024). ### 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.6.7~0.7.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![image](https://github.com/user-attachments/assets/299b9e6c-58b5-4700-b09e-b03b239e7170) When there are too many commands, the content returned by the prompt generator is incomplete. This issue has been tested and reproduced multiple times. ### ✔️ Expected Behavior I expect the prompt generator to return complete content. ### ❌ Actual Behavior The content returned by the prompt generator is not exactly what I want, especially the second half, where the examples are incomplete. This leads to poor output quality.
yindo added the 🐞 bug label 2026-02-21 18:10:47 -05:00
yindo closed this issue 2026-02-21 18:10:47 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 4, 2024):

To fix the issue where the prompt generator returns incomplete content when there are too many commands in Dify version 0.6.7~0.7.3, you should set Stop Sequences. This will inform the LLM to stop generating text at specific points, preventing it from producing incomplete content.

Here’s how you can set Stop Sequences:

  1. Identify the specific words, phrases, or characters that should signal the LLM to stop generating text. For example, if you have a prompt like:

    Human1: What color is the sky?
    Assistant1: The sky is blue.
    Human1: What color is fire?
    Assistant1: Fire is red.
    Human1: What color is soil?
    Assistant1: 
    
  2. In the model parameters' Stop Sequences, input Human1:, and press the "Tab" key.

    This way, the LLM will only respond with one sentence:

    Assistant1: Soil is yellow.
    

    And will not generate additional dialogue (i.e., the LLM will stop generating content before reaching the next "Human1:").

By setting the appropriate stop sequences, you can control the output length and ensure that the content generated is complete and as expected [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 4, 2024): <!-- Answer --> To fix the issue where the prompt generator returns incomplete content when there are too many commands in Dify version 0.6.7~0.7.3, you should set **Stop Sequences**. This will inform the LLM to stop generating text at specific points, preventing it from producing incomplete content. Here’s how you can set **Stop Sequences**: 1. Identify the specific words, phrases, or characters that should signal the LLM to stop generating text. For example, if you have a prompt like: ```plaintext Human1: What color is the sky? Assistant1: The sky is blue. Human1: What color is fire? Assistant1: Fire is red. Human1: What color is soil? Assistant1: ``` 2. In the model parameters' `Stop Sequences`, input `Human1:`, and press the "Tab" key. This way, the LLM will only respond with one sentence: ```plaintext Assistant1: Soil is yellow. ``` And will not generate additional dialogue (i.e., the LLM will stop generating content before reaching the next "Human1:"). By setting the appropriate stop sequences, you can control the output length and ensure that the content generated is complete and as expected <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/learn-more/prompt-engineering/prompt-engineering-1/README.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@Sakura4036 commented on GitHub (Sep 5, 2024):

You can generate longer prompts by setting the env environment variable PROMPT_GENERATION_MAX_TOKENS in .env file, the default value is 512.

@Sakura4036 commented on GitHub (Sep 5, 2024): You can generate longer prompts by setting the env environment variable `PROMPT_GENERATION_MAX_TOKENS` in `.env` file, the default value is `512`.
Author
Owner

@GeorgeGalway commented on GitHub (Sep 5, 2024):

You can generate longer prompts by setting the env environment variable PROMPT_GENERATION_MAX_TOKENS in .env file, the default value is 512.

image
However, configuring it in the env didn’t work, including placing it in the api/.env file and docker/.env file.

@GeorgeGalway commented on GitHub (Sep 5, 2024): > You can generate longer prompts by setting the env environment variable `PROMPT_GENERATION_MAX_TOKENS` in `.env` file, the default value is `512`. ![image](https://github.com/user-attachments/assets/1a1f3009-bef5-4aef-99a3-d491f268708e) However, configuring it in the env didn’t work, including placing it in the api/.env file and docker/.env file.
Author
Owner

@Sakura4036 commented on GitHub (Sep 5, 2024):

I set PROMPT_GENERATION_MAX_TOKENS=2048 works for me. Maybe you should check your docker config file.

  • PROMPT_GENERATION_MAX_TOKENS=2048
    image
  • PROMPT_GENERATION_MAX_TOKENS=256
    image

Although the generated prompts are shorter and incomplete, they are not the maximum length I set, which may be a problem.

@Sakura4036 commented on GitHub (Sep 5, 2024): I set `PROMPT_GENERATION_MAX_TOKENS=2048` works for me. Maybe you should check your docker config file. - PROMPT_GENERATION_MAX_TOKENS=2048 ![image](https://github.com/user-attachments/assets/cf46d44b-def5-457f-9aa7-cd7cc76dce82) - PROMPT_GENERATION_MAX_TOKENS=256 ![image](https://github.com/user-attachments/assets/ebcdc70d-0ddb-4b58-88b6-1488a73076d5) Although the generated prompts are shorter and incomplete, they are not the maximum length I set, which may be a problem.
Author
Owner

@GeorgeGalway commented on GitHub (Sep 5, 2024):

我设置PROMPT_GENERATION_MAX_TOKENS=2048成功了。也许你应该检查一下你的 docker 配置文件。

  • PROMPT_GENERATION_MAX_TOKENS=2048
    图像
  • PROMPT_GENERATION_MAX_TOKENS=256
    图像

虽然生成的提示比较短而且不完整,但是都不是我设定的最大长度,这可能是一个问题。

Is your env file located at /docker/.env or /api/.env?

@GeorgeGalway commented on GitHub (Sep 5, 2024): > 我设置`PROMPT_GENERATION_MAX_TOKENS=2048`成功了。也许你应该检查一下你的 docker 配置文件。 > > * PROMPT_GENERATION_MAX_TOKENS=2048 > ![图像](https://private-user-images.githubusercontent.com/42060616/364667375-cf46d44b-def5-457f-9aa7-cd7cc76dce82.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1MjQ4MDAsIm5iZiI6MTcyNTUyNDUwMCwicGF0aCI6Ii80MjA2MDYxNi8zNjQ2NjczNzUtY2Y0NmQ0NGItZGVmNS00NTdmLTlhYTctY2Q3Y2M3NmRjZTgyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA1VDA4MjE0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMxZjk4OGZiZTIzMzdhMzU0YTFiNjkzNjEzYWExMWE1ODY1NDQzYjZlNTYyMmJkYmQyODIzY2UwMTk1MmM3NTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sZdO-VTxeKhFgYjiinLQdu6LSl1fP-TlZ-KYlQKKd8Y) > * PROMPT_GENERATION_MAX_TOKENS=256 > ![图像](https://private-user-images.githubusercontent.com/42060616/364668043-ebcdc70d-0ddb-4b58-88b6-1488a73076d5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1MjQ4MDAsIm5iZiI6MTcyNTUyNDUwMCwicGF0aCI6Ii80MjA2MDYxNi8zNjQ2NjgwNDMtZWJjZGM3MGQtMGRkYi00YjU4LTg4YjYtMTQ4OGE3MzA3NmQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA1VDA4MjE0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI5MDIzOTU2ZDc1MmM2OGIyOWEyZTk3ZWZkNTdhZTI3ZjA1ZDE5YzBiYzg1YTY5OTk2ZTFkOTBiYTQxYzYwNDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.XIFGE-_9prBL4Aw2Nxf6RGQqaHPkWaB2znqSIIM0ABw) > > 虽然生成的提示比较短而且不完整,但是都不是我设定的最大长度,这可能是一个问题。 Is your env file located at `/docker/.env` or `/api/.env`?
Author
Owner

@Sakura4036 commented on GitHub (Sep 5, 2024):

Self Hosted (Source) depolyment, so i use api/.env file for configuration

@Sakura4036 commented on GitHub (Sep 5, 2024): Self Hosted (Source) depolyment, so i use `api/.env` file for configuration
Author
Owner

@GeorgeGalway commented on GitHub (Sep 5, 2024):

Self Hosted (Source) depolyment, so i use api/.env file for configuration

Thanks for getting back to me.
Self Hosted (Docker),regardless of whether it's in /api/.env or /docker/.env, the PROMPT_GENERATION_MAX_TOKENS parameter isn't having any effect.

@GeorgeGalway commented on GitHub (Sep 5, 2024): > Self Hosted (Source) depolyment, so i use `api/.env` file for configuration Thanks for getting back to me. Self Hosted (Docker),regardless of whether it's in `/api/.env` or `/docker/.env`, the `PROMPT_GENERATION_MAX_TOKENS` parameter isn't having any effect.
Author
Owner

@Sakura4036 commented on GitHub (Sep 5, 2024):

@crazywoola Could you offer some help?

@Sakura4036 commented on GitHub (Sep 5, 2024): @crazywoola Could you offer some help?
Author
Owner

@nadirvishun commented on GitHub (Oct 23, 2024):

Self Hosted (Source) depolyment, so i use api/.env file for configuration

Thanks for getting back to me. Self Hosted (Docker),regardless of whether it's in /api/.env or /docker/.env, the PROMPT_GENERATION_MAX_TOKENS parameter isn't having any effect.

It seems that we also need to configure x-shared-env: in docker-compose.yaml to include PROMPT_GENERATION_MAX_TOKENS, because docker/.env is on the host machine and does not affect the docker environment. It can only take effect after being transformed through the environment in docker-compose.yaml. However, both the .env file and docker-compose.yaml in the docker self hosted lack the PROMPT_GENERATION_MAX_TOKENS parameter, which is a bug.

@nadirvishun commented on GitHub (Oct 23, 2024): > > Self Hosted (Source) depolyment, so i use `api/.env` file for configuration > > Thanks for getting back to me. Self Hosted (Docker),regardless of whether it's in `/api/.env` or `/docker/.env`, the `PROMPT_GENERATION_MAX_TOKENS` parameter isn't having any effect. It seems that we also need to configure `x-shared-env:` in `docker-compose.yaml` to include `PROMPT_GENERATION_MAX_TOKENS`, because `docker/.env` is on the host machine and does not affect the docker environment. It can only take effect after being transformed through the `environment` in `docker-compose.yaml`. However, both the `.env` file and `docker-compose.yaml` in the docker self hosted lack the `PROMPT_GENERATION_MAX_TOKENS` parameter, which is a bug.
Author
Owner

@mr-v-v-v commented on GitHub (Mar 10, 2025):

+1

I have the same thing. I'm surprised this problem still exists.
I can't get a full response from the agent. He keeps shortening the response. PROMPT_GENERATION_MAX_TOKENS didn't help me in the .env file.

Version: 0.15.3

@mr-v-v-v commented on GitHub (Mar 10, 2025): +1 I have the same thing. I'm surprised this problem still exists. I can't get a full response from the agent. He keeps shortening the response. PROMPT_GENERATION_MAX_TOKENS didn't help me in the .env file. Version: 0.15.3
Author
Owner

@pennn778 commented on GitHub (Jun 16, 2025):

  • If you run Dify in Docker, you can modify PROMPT_GENERATION_MAX_TOKENS=512 in dify/docker/.env .
  • And rebuild docker:
    • sudo docker-compose down
    • sudo docker-compose up -d
@pennn778 commented on GitHub (Jun 16, 2025): - If you run Dify in Docker, you can modify `PROMPT_GENERATION_MAX_TOKENS=512` in `dify/docker/.env` . - And rebuild docker: - `sudo docker-compose down` - `sudo docker-compose up -d`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5396