dify icon indicating copy to clipboard operation
dify copied to clipboard

Got unknown type role=<PromptMessageRole.TOOL:'tool'>

Open drfenixlinghu opened this issue 2 years ago • 11 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] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

every time i use a tool in the agent mode, after the tool perform its job, the agent no longer accept any further prompts. seems the agent feels that it has used the tool and the tool has done the job, therefore no more action is required or accepted. This happens with all tools available to dify. d1ed109e672c393659c6f3c2e928385 0efff3d09b4986e4a6f215f96423143

anyone has the same issue?

✔️ Expected Behavior

to be able to continue with the conversation

❌ Actual Behavior

cannot go on with the conversation.

drfenixlinghu avatar Jun 18 '24 09:06 drfenixlinghu

Hello @drfenixlinghu! I'm here to assist you with bug fixes, answer questions, and guide you on becoming a contributor. Let's tackle this issue together!

Yes, the issue you described with Dify version 0.6.11, where the agent no longer accepts further prompts after a tool has completed its task and throws an error indicating an unknown type role with role=<PromptMessageRole.TOOL: 'tool'>, has been experienced by others. The provided code defines the PromptMessageRole enum, which includes the TOOL role, and the ToolPromptMessage class, which uses this role. The error might be due to improper handling or validation of the TOOL role in the system.

From the api/core/agent/base_agent_runner.py file, it appears that the BaseAgentRunner class initializes and manages tools through methods like _init_prompt_tools and _convert_tool_to_prompt_message_tool. These methods ensure that tools are properly converted to PromptMessageTool instances and their parameters are correctly set. However, if there is an issue with how the TOOL role is being processed or validated, it could lead to the error you are encountering. It might be worth checking the implementation of these methods and ensuring that the TOOL role is being handled correctly throughout the agent's lifecycle [1][2].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Jun 18 '24 09:06 dosubot[bot]

I think this should be fixed in latest main branch.

crazywoola avatar Jun 18 '24 09:06 crazywoola

the error exist a long time since 0.6.10 and can't resolved at 0.6.11

cjdxhjj avatar Jun 18 '24 09:06 cjdxhjj

Link https://github.com/langgenius/dify/issues/5304

crazywoola avatar Jun 18 '24 10:06 crazywoola

Yes we just fixed yesterday. https://github.com/langgenius/dify/pull/5245

crazywoola avatar Jun 18 '24 10:06 crazywoola

Yes we just fixed yesterday. #5245

updated today the problem is still there

drfenixlinghu avatar Jun 18 '24 12:06 drfenixlinghu

最新mast版本, sd遇到同样错误

mmm8955405 avatar Jun 24 '24 03:06 mmm8955405

which model are you using for this?

Yeuoly avatar Jun 24 '24 08:06 Yeuoly

@Yeuoly I'm using GLM-4 with the same problem.

fandych avatar Jun 24 '24 09:06 fandych

Does this problem have been fixed until now? @crazywoola

dyz1027543829 avatar Jul 30 '24 08:07 dyz1027543829

Does this problem have been fixed until now? @crazywoola

I think it can be closed. It was fixed from v0.6.13.

fandych avatar Aug 02 '24 05:08 fandych