dify icon indicating copy to clipboard operation
dify copied to clipboard

Agent app got incomplete answer in a long conversation

Open zeroameli opened this issue 11 months ago • 5 comments

Self Checks

  • [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] Pleas do not modify this template :) and fill in all the required fields.

Provide a description of the help you need

How to reproduce:

  • Create an agent type app and keep talking to it in a conversation until it output an incomplete answer.

Debuging:

  • Agent type app use assistant_base_runner to run. According to https://github.com/langgenius/dify/pull/2495, it will take all the history messages as prompt messages. Therefore, prompt messages will become larger and larger when keep talking in a same conversation.
  • When the prompt_tokens is greater than model_context_tokens, max_tokens will be fixed to 16. It limits the llm model output and result in an incomplete answer. https://github.com/langgenius/dify/blob/16af509c4651f1493fcb59e549bdb984ad54a183/api/core/app_runner/app_runner.py#L114-L115

Any ideas to solve this problem?

zeroameli avatar Mar 21 '24 15:03 zeroameli

It's great to see that you've identified the issue and provided a detailed description of the problem. Your understanding of the code and the potential impact on the application is impressive. If you have any ideas for solving the problem, feel free to propose a solution or even create a pull request. Your contribution would be valuable to the project. Keep up the good work!

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

dosubot[bot] avatar Mar 21 '24 15:03 dosubot[bot]

Got that, I missed recalc the prompt messages, It will be solved soon.

Yeuoly avatar Mar 22 '24 03:03 Yeuoly

I encountered it too. Has it been fixed?

wangrg avatar Apr 11 '24 01:04 wangrg

When is this issue expected to be fixed? It still persists in Dify 0.6.6.

git-meteor avatar May 07 '24 02:05 git-meteor