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

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

Originally created by @drfenixlinghu on GitHub (Jun 18, 2024).

Originally assigned to: @Yeuoly 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).
  • 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.

Originally created by @drfenixlinghu on GitHub (Jun 18, 2024). Originally assigned to: @Yeuoly 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] 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](https://github.com/langgenius/dify/assets/156991093/f24c4ac8-b70d-405a-9f6e-65dd9962a8c6) ![0efff3d09b4986e4a6f215f96423143](https://github.com/langgenius/dify/assets/156991093/53437151-8d53-4951-86d2-30552866a5ca) anyone has the same issue? ### ✔️ Expected Behavior to be able to continue with the conversation ### ❌ Actual Behavior cannot go on with the conversation.
yindo added the 🐞 bug label 2026-02-21 18:04:59 -05:00
yindo closed this issue 2026-02-21 18:04:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 18, 2024):

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] commented on GitHub (Jun 18, 2024): <!-- Greeting --> 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! <!-- Answer --> 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 <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/entities/message_entities.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/agent/base_agent_runner.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Jun 18, 2024):

I think this should be fixed in latest main branch.

@crazywoola commented on GitHub (Jun 18, 2024): I think this should be fixed in latest main branch.
Author
Owner

@cjdxhjj commented on GitHub (Jun 18, 2024):

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

@cjdxhjj commented on GitHub (Jun 18, 2024): the error exist a long time since 0.6.10 and can't resolved at 0.6.11
Author
Owner

@crazywoola commented on GitHub (Jun 18, 2024):

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

@crazywoola commented on GitHub (Jun 18, 2024): Link https://github.com/langgenius/dify/issues/5304
Author
Owner

@crazywoola commented on GitHub (Jun 18, 2024):

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

@crazywoola commented on GitHub (Jun 18, 2024): Yes we just fixed yesterday. https://github.com/langgenius/dify/pull/5245
Author
Owner

@drfenixlinghu commented on GitHub (Jun 18, 2024):

Yes we just fixed yesterday. #5245

updated today the problem is still there

@drfenixlinghu commented on GitHub (Jun 18, 2024): > Yes we just fixed yesterday. #5245 updated today the problem is still there
Author
Owner

@mmm8955405 commented on GitHub (Jun 23, 2024):

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

@mmm8955405 commented on GitHub (Jun 23, 2024): 最新mast版本, sd遇到同样错误
Author
Owner

@Yeuoly commented on GitHub (Jun 24, 2024):

which model are you using for this?

@Yeuoly commented on GitHub (Jun 24, 2024): which model are you using for this?
Author
Owner

@fandych commented on GitHub (Jun 24, 2024):

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

@fandych commented on GitHub (Jun 24, 2024): @Yeuoly I'm using GLM-4 with the same problem.
Author
Owner

@dyz1027543829 commented on GitHub (Jul 30, 2024):

Does this problem have been fixed until now? @crazywoola

@dyz1027543829 commented on GitHub (Jul 30, 2024): Does this problem have been fixed until now? @crazywoola
Author
Owner

@fandych commented on GitHub (Aug 2, 2024):

Does this problem have been fixed until now? @crazywoola

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

@fandych commented on GitHub (Aug 2, 2024): > Does this problem have been fixed until now? @crazywoola I think it can be closed. It was fixed from v0.6.13.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4152