When I call the function call of qwen-qwq, I get an Error: list index out of range #62

Closed
opened 2026-02-16 10:17:57 -05:00 by yindo · 7 comments
Owner

Originally created by @YinSonglin1997 on GitHub (Mar 10, 2025).

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.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I executed the following command in the background:
python -m vllm.entrypoints.openai.api_server --model /mnt2/ysl/QwQ-32B --tensor_parallel_size 4 --enable-auto-tool-choice --tool-call-parser hermes --trust-remote-code --max-model-len 131072 --host 0.0.0.0 --port 8000
However, the agent application cannot call the tool, and an error "list index out of range" is reported. How can I solve this problem?

Image

✔️ Expected Behavior

Correct call tool

Actual Behavior

Unable to call tool

Originally created by @YinSonglin1997 on GitHub (Mar 10, 2025). ### 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.15.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I executed the following command in the background: ` python -m vllm.entrypoints.openai.api_server --model /mnt2/ysl/QwQ-32B --tensor_parallel_size 4 --enable-auto-tool-choice --tool-call-parser hermes --trust-remote-code --max-model-len 131072 --host 0.0.0.0 --port 8000 ` However, the agent application cannot call the tool, and an error "list index out of range" is reported. How can I solve this problem? ![Image](https://github.com/user-attachments/assets/032c49e6-c1ad-43ed-b094-8f23813ff814) ### ✔️ Expected Behavior Correct call tool ### ❌ Actual Behavior Unable to call tool
yindo closed this issue 2026-02-16 10:17:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 10, 2025):

The "list index out of range" error you're encountering when calling a tool in the Dify platform can occur due to several reasons related to how tool parameters and responses are handled. Here are some potential causes and solutions:

  1. Tool Parameters Handling: Ensure that the tool parameters are correctly formatted and match the expected number of parameters. If the tool expects a specific number of parameters and the provided parameters do not match, it could lead to accessing an index that does not exist. Check the conversion of tool_parameters from a string to a dictionary and ensure that the parameters list is not empty when accessed [1].

  2. Tool Response Handling: Verify that the tool response list contains the expected elements. If the tool response list is empty or does not contain the expected message types, iterating over it or accessing specific indices could lead to an index error. Ensure that the tool response is correctly populated before processing [1].

  3. Binary and Text Extraction: Check the extraction of binary and text from the tool response. If the tool response list is expected to have certain elements and it doesn't, accessing specific indices could lead to an index error. Make sure that the tool response contains the necessary metadata and message types [1].

Review these areas in your code to ensure that the tool parameters and responses are correctly handled. Adjust the logic to prevent accessing indices that may not exist, and ensure that all expected data is present before processing.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 10, 2025): <!-- Answer --> The "list index out of range" error you're encountering when calling a tool in the Dify platform can occur due to several reasons related to how tool parameters and responses are handled. Here are some potential causes and solutions: 1. **Tool Parameters Handling**: Ensure that the tool parameters are correctly formatted and match the expected number of parameters. If the tool expects a specific number of parameters and the provided parameters do not match, it could lead to accessing an index that does not exist. Check the conversion of `tool_parameters` from a string to a dictionary and ensure that the parameters list is not empty when accessed <sup>[[1]](https://github.com/langgenius/dify/blob/2968482199983c3d914f395bd04078bb2612522a/api/core/tools/tool_engine.py)</sup>. 2. **Tool Response Handling**: Verify that the tool response list contains the expected elements. If the tool response list is empty or does not contain the expected message types, iterating over it or accessing specific indices could lead to an index error. Ensure that the tool response is correctly populated before processing <sup>[[1]](https://github.com/langgenius/dify/blob/2968482199983c3d914f395bd04078bb2612522a/api/core/tools/tool_engine.py)</sup>. 3. **Binary and Text Extraction**: Check the extraction of binary and text from the tool response. If the tool response list is expected to have certain elements and it doesn't, accessing specific indices could lead to an index error. Make sure that the tool response contains the necessary metadata and message types <sup>[[1]](https://github.com/langgenius/dify/blob/2968482199983c3d914f395bd04078bb2612522a/api/core/tools/tool_engine.py)</sup>. Review these areas in your code to ensure that the tool parameters and responses are correctly handled. Adjust the logic to prevent accessing indices that may not exist, and ensure that all expected data is present before processing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/557efddb-1820-4328-8361-e9e2b60b33e5?feedback_type=other)</sup>
Author
Owner

@zhangao0086 commented on GitHub (Mar 10, 2025):

What does the list api of vllm return? Additionally, can it be successfully called in the terminal, for example, using curl?

@zhangao0086 commented on GitHub (Mar 10, 2025): What does the list api of vllm return? Additionally, can it be successfully called in the terminal, for example, using curl?
Author
Owner

@YinSonglin1997 commented on GitHub (Mar 10, 2025):

Can be called correctly, but also return the tool parameters. I wonder if there is a problem in the dify background when parsing Function.

Image

@YinSonglin1997 commented on GitHub (Mar 10, 2025): Can be called correctly, but also return the tool parameters. I wonder if there is a problem in the dify background when parsing Function. ![Image](https://github.com/user-attachments/assets/52ea297e-520a-40b6-a78b-45cff4fae7bd)
Author
Owner

@zhangao0086 commented on GitHub (Mar 10, 2025):

You can pinpoint the root cause of an error by examining the logs of the API container. Here's an example command to view these logs:

docker logs -f --tail 500 docker-api-1

It's possible that there are some incompatibilities in the implementation of openai_api_compatible:
https://github.com/langgenius/dify/blob/0.15.3/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py#L291

@zhangao0086 commented on GitHub (Mar 10, 2025): You can pinpoint the root cause of an error by examining the logs of the API container. Here's an example command to view these logs: ``` docker logs -f --tail 500 docker-api-1 ``` It's possible that there are some incompatibilities in the implementation of `openai_api_compatible`: https://github.com/langgenius/dify/blob/0.15.3/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py#L291
Author
Owner

@chiehw commented on GitHub (Apr 24, 2025):

I tried to fix this problem and it worked fine on my model (Qwen2.5-32B)

@chiehw commented on GitHub (Apr 24, 2025): I tried to fix this problem and it worked fine on my model (Qwen2.5-32B)
Author
Owner

@YinSonglin1997 commented on GitHub (Apr 24, 2025):

Have you upgraded to the vllm version? I upgraded vllm and added --tool-call-paraser

@YinSonglin1997 commented on GitHub (Apr 24, 2025): Have you upgraded to the vllm version? I upgraded vllm and added `--tool-call-paraser`
Author
Owner

@chiehw commented on GitHub (Apr 24, 2025):

It has nothing to do with vllm. This error is caused by dify.

@chiehw commented on GitHub (Apr 24, 2025): It has nothing to do with vllm. This error is caused by dify.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#62