llm call tools error #5409

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

Originally created by @kenneth-bro on GitHub (Sep 5, 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.7.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

image
After the LLM is equipped with the tool Current_time, the tool call error will often appear, and the frequency will be relatively high. Why is this?

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @kenneth-bro on GitHub (Sep 5, 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.7.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![image](https://github.com/user-attachments/assets/c57b42b5-b697-4a68-9e7f-21c427505be9) After the LLM is equipped with the tool Current_time, the tool call error will often appear, and the frequency will be relatively high. Why is this? ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:10:50 -05:00
yindo closed this issue 2026-02-21 18:10:51 -05:00
Author
Owner

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

I found a similar unsolved discussion and two closed issues that might be relevant to your problem:

  1. add self deploy llm model, add error. (Unsolved)
  2. Error is displayed in selecting the tool for the Agent APP (Closed)
    • Suggested solutions include checking tool provider credentials, ensuring the tool name is correct, validating tool parameters, and handling general exceptions.
  3. doubao tools call error (Closed)
    • This issue was resolved by a pull request that added support for Moonshot and GLM models tool call for the Volc Ark provider.

Regarding the specific issue with the Current_time tool in Dify version 0.7.3, the frequent tool call errors are likely due to the handling of tool parameters. If the tool parameters are provided as a string and the tool expects a dictionary, a ValueError is raised. This is evident in the agent_invoke method of the ToolEngine class:

if isinstance(tool_parameters, str):
    # check if this tool has only one parameter
    parameters = [
        parameter for parameter in tool.get_runtime_parameters() or []
        if parameter.form == ToolParameter.ToolParameterForm.LLM
    ]
    if parameters and len(parameters) == 1:
        tool_parameters = {
            parameters[0].name: tool_parameters
        }
    else:
        raise ValueError(f"tool_parameters should be a dict, but got a string: {tool_parameters}")

Additionally, the FunctionCallAgentRunner class processes tool calls from the response. If the Current_time tool's parameters are not correctly formatted or if there are issues in extracting the tool calls, this can lead to frequent errors. The methods check_tool_calls, check_blocking_tool_calls, extract_tool_calls, and extract_blocking_tool_calls are responsible for identifying and extracting these tool calls, and any issues in these methods can contribute to the errors [1][2][3].

The specific error message generated when the tool call error occurs with the Current_time tool is:

Invalid timezone: {tz}

This message is returned when the provided timezone is invalid and cannot be recognized by the pytz_timezone function [4].

To mitigate these issues, ensure that the tool parameters are correctly formatted as a dictionary and that the timezone provided is valid.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 5, 2024): <!-- Answer --> I found a similar unsolved discussion and two closed issues that might be relevant to your problem: 1. [add self deploy llm model, add error.](https://github.com/langgenius/dify/discussions/5985) (Unsolved) 2. [Error is displayed in selecting the tool for the Agent APP](https://github.com/langgenius/dify/issues/7519) (Closed) - Suggested solutions include checking tool provider credentials, ensuring the tool name is correct, validating tool parameters, and handling general exceptions. 3. [doubao tools call error](https://github.com/langgenius/dify/issues/7669) (Closed) - This issue was resolved by a pull request that added support for Moonshot and GLM models tool call for the Volc Ark provider. Regarding the specific issue with the `Current_time` tool in Dify version 0.7.3, the frequent tool call errors are likely due to the handling of tool parameters. If the tool parameters are provided as a string and the tool expects a dictionary, a `ValueError` is raised. This is evident in the `agent_invoke` method of the `ToolEngine` class: ```python if isinstance(tool_parameters, str): # check if this tool has only one parameter parameters = [ parameter for parameter in tool.get_runtime_parameters() or [] if parameter.form == ToolParameter.ToolParameterForm.LLM ] if parameters and len(parameters) == 1: tool_parameters = { parameters[0].name: tool_parameters } else: raise ValueError(f"tool_parameters should be a dict, but got a string: {tool_parameters}") ``` Additionally, the `FunctionCallAgentRunner` class processes tool calls from the response. If the `Current_time` tool's parameters are not correctly formatted or if there are issues in extracting the tool calls, this can lead to frequent errors. The methods `check_tool_calls`, `check_blocking_tool_calls`, `extract_tool_calls`, and `extract_blocking_tool_calls` are responsible for identifying and extracting these tool calls, and any issues in these methods can contribute to the errors <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/tools/tool_engine.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/agent/fc_agent_runner.py)</sup>. The specific error message generated when the tool call error occurs with the `Current_time` tool is: ``` Invalid timezone: {tz} ``` This message is returned when the provided timezone is invalid and cannot be recognized by the `pytz_timezone` function <sup>[[4]](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/builtin/time/tools/current_time.py)</sup>. To mitigate these issues, ensure that the tool parameters are correctly formatted as a dictionary and that the timezone provided is valid. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

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

Try to use a smarter LLM. For those providers which do not support FC will use ReACT by default. So this happens.

@crazywoola commented on GitHub (Sep 5, 2024): Try to use a smarter LLM. For those providers which do not support FC will use ReACT by default. So this happens.
Author
Owner

@kenneth-bro commented on GitHub (Sep 5, 2024):

Try to use a smarter LLM. For those providers which do not support FC will use ReACT by default. So this happens.

Deepseek is to support Tools Call.must be support the function call?

@kenneth-bro commented on GitHub (Sep 5, 2024): > Try to use a smarter LLM. For those providers which do not support FC will use ReACT by default. So this happens. Deepseek is to support Tools Call.must be support the function call?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5409