In the Agent-type application, an error occurred when using the tool: The length of output variable result must be less than 30. #13466

Closed
opened 2026-02-21 19:12:17 -05:00 by yindo · 2 comments
Owner

Originally created by @shaunsyb on GitHub (Apr 28, 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

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I used a self-developed workflow as a tool in the application and invoked it in the prompt. This workflow will return the corresponding knowledge base content to the large model based on the user's input information. The return format is a JSON. However, some input requests from users now cause errors. When I manually execute the workflow by substituting the parameters into it, the workflow can be executed normally. I don't know how to handle this limitation. The screenshot of the error is as follows:

Image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @shaunsyb on GitHub (Apr 28, 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 1.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I used a self-developed workflow as a tool in the application and invoked it in the prompt. This workflow will return the corresponding knowledge base content to the large model based on the user's input information. The return format is a JSON. However, some input requests from users now cause errors. When I manually execute the workflow by substituting the parameters into it, the workflow can be executed normally. I don't know how to handle this limitation. The screenshot of the error is as follows: ![Image](https://github.com/user-attachments/assets/8bcca75f-106e-414d-845e-a71e49add18e) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 19:12:17 -05:00
Author
Owner

@crazywoola commented on GitHub (Apr 28, 2025):

https://github.com/langgenius/dify/blob/6d9dd3109e807f0648a1fe7d0844c766717488b4/api/configs/feature/__init__.py#L120-L138

Please read the docs and search existing issues first. :)

@crazywoola commented on GitHub (Apr 28, 2025): https://github.com/langgenius/dify/blob/6d9dd3109e807f0648a1fe7d0844c766717488b4/api/configs/feature/__init__.py#L120-L138 Please read the docs and search existing issues first. :)
Author
Owner

@dosubot[bot] commented on GitHub (Apr 28, 2025):

I found a similar discussion thread titled "In the Agent-type application, an error occurred when using the tool: The length of output variable result must be less than 30" which is currently unsolved [1].

To resolve the error "The length of output variable result must be less than 30," ensure that the output variable result in your workflow tool does not exceed the maximum length defined by dify_config.CODE_MAX_STRING_LENGTH. This error is raised when the length of the output string exceeds the configured maximum length [2].

You can resolve this by:

  1. Checking the value of dify_config.CODE_MAX_STRING_LENGTH and ensuring that your output variable result is less than this length. The default value is 10000 [3].
  2. Modifying your workflow tool to truncate or adjust the output variable result to comply with this length restriction.

Additionally, you can configure or change the dify_config.CODE_MAX_STRING_LENGTH in a self-hosted Dify setup by setting the environment variable CODE_MAX_STRING_LENGTH in the docker/.env file [3].

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 (Apr 28, 2025): <!-- Answer --> I found a similar discussion thread titled "In the Agent-type application, an error occurred when using the tool: The length of output variable result must be less than 30" which is currently unsolved <sup>[[1]](https://github.com/langgenius/dify/discussions/18978)</sup>. To resolve the error "The length of output variable result must be less than 30," ensure that the output variable `result` in your workflow tool does not exceed the maximum length defined by `dify_config.CODE_MAX_STRING_LENGTH`. This error is raised when the length of the output string exceeds the configured maximum length <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py)</sup>. You can resolve this by: 1. Checking the value of `dify_config.CODE_MAX_STRING_LENGTH` and ensuring that your output variable `result` is less than this length. The default value is 10000 <sup>[[3]](https://github.com/langgenius/dify/issues/18731)</sup>. 2. Modifying your workflow tool to truncate or adjust the output variable `result` to comply with this length restriction. Additionally, you can configure or change the `dify_config.CODE_MAX_STRING_LENGTH` in a self-hosted Dify setup by setting the environment variable `CODE_MAX_STRING_LENGTH` in the `docker/.env` file <sup>[[3]](https://github.com/langgenius/dify/issues/18731)</sup>. <!-- 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/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/dbfcfa94-ad90-4aa3-904c-5ad851da3a00?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13466