dify icon indicating copy to clipboard operation
dify copied to clipboard

the parameter extraction node out log "__reason": "Invalid number of parameters"

Open doonygit opened this issue 8 months ago • 1 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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

In the workflow, the parameter extraction node reports an exception, but during single-node debugging, there is no exception under the same parameter conditions.

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

doonygit avatar Apr 25 '25 08:04 doonygit

The "Invalid number of parameters" error in the parameter extraction node typically occurs when there is a mismatch between the expected parameters and the extracted parameters. Here are some steps you can take to resolve this issue:

  1. Check Parameter Definitions: Ensure that the number of parameters defined in your data matches the number of parameters expected in the result. Verify that all required parameters are present and correctly formatted according to their specified types, such as 'select', 'number', or 'bool' [1].

  2. Model Selection: If you are using the QwQ-32B-Preview model, consider switching to a non-reasoning model. The QwQ-32B-Preview model may have limitations in parameter extraction tasks [1].

  3. Inference Mode: Use the appropriate inference mode (function/tool call or prompt) based on the model's capabilities to improve parameter extraction accuracy [1].

  4. Payload Validation: Ensure that the payload includes a valid query and model provider, as these are required fields. The parameters themselves must have a name, type, and description [1].

  5. Vision Configuration: If the vision mode is enabled, verify that the vision configuration includes a variable selector [1].

These steps should help you address the "Invalid number of parameters" error in your self-hosted Docker setup.

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] avatar Apr 25 '25 08:04 dosubot[bot]

Image

If some parameters in parametes list is not required, extracted result from LLM will miss these parameters. It is acceptable for user if miss paramters will be filled with default value according to their type, but it can not pass this condition showing above image.

Of course, we can add extra prompt to tell LLM: "The parameter that did not appear retains the field name in the return result, but the parameter value is an empty string"

Shall we replace the condition with setting default value? Thanks for your consideration.

wickhu avatar May 13 '25 06:05 wickhu

@crazywoola Hey, sorry about disturb, but in Dify 1.9.2, I still face this issue. Why this issue be marked as completed? Maybe we need to further talk about this issue and fix it. If comment previous issue does not comply with community standards, I will try to new a issue, please tell me how to do next!

As wickhu said, this line actually incorrect: https://github.com/langgenius/dify/blob/9843fec3931ba791b09a3805e44fbe6636191996/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py#L543

If parameter extraction node have some non-required parameter, because of result field is extract by model, and prompt did not have any handler about non-required parameter, so len(result) length is likely that it will not be equal to len(data.parameters), InvalidNumberOfParametersError will have high probability raise.

Additionally, I found another issue that can also cause this error. _extract_complete_json_response maybe also have some bug: https://github.com/langgenius/dify/blob/9843fec3931ba791b09a3805e44fbe6636191996/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py#L654-L667

For example, if reasoning model return thinking text have some json text, or normal model return text have some json unrelated to the final result, _extract_complete_json_response just extract the first json data, IMO it will cause some problem. It also will cause InvalidNumberOfParametersError.

Image

It will extract failed.

https://github.com/langgenius/dify/issues/16152#issuecomment-2757328158 As you said, the reasoning model is not good at extracting parameters, but non-reasoning model maybe also have cause problem.

CrabSAMA avatar Nov 10 '25 08:11 CrabSAMA