Is it possible to modify the restrictions ”Depth limit $5 reached, object too deep. “ #8029

Closed
opened 2026-02-21 18:23:34 -05:00 by yindo · 7 comments
Owner

Originally created by @imfeisir on GitHub (Feb 6, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

Image I need to frequently handle HTTP requests that return JSON text, I need to convert it to a JSON object through Python, but it always reports an error Is it possible to remove the depth limit of the error prompt here, or modify the configuration?
Originally created by @imfeisir on GitHub (Feb 6, 2025). ### Self Checks - [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 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. ### Provide a description of requested docs changes <img width="427" alt="Image" src="https://github.com/user-attachments/assets/912b4c44-5119-4963-a8ec-26b12ca8f158" /> I need to frequently handle HTTP requests that return JSON text, I need to convert it to a JSON object through Python, but it always reports an error Is it possible to remove the depth limit of the error prompt here, or modify the configuration?
yindo closed this issue 2026-02-21 18:23:34 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 6, 2025):

Hello @imfeisir! 👋 I'm here to help you with bug fixes, answer your questions, and guide you on becoming a contributor.

Yes, you can modify the depth limit for JSON objects in Dify. The CODE_MAX_DEPTH setting, which determines the maximum allowed depth for nested structures, can be adjusted using an environment variable. This setting is defined in the dify_config module and is used in the CodeNode class to enforce the depth limit during code execution. By setting the CODE_MAX_DEPTH environment variable, you can increase the maximum depth allowed for your JSON objects [1][2].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 6, 2025): <!-- Greeting --> Hello @imfeisir! 👋 I'm here to help you with bug fixes, answer your questions, and guide you on becoming a contributor. <!-- Answer --> Yes, you can modify the depth limit for JSON objects in Dify. The `CODE_MAX_DEPTH` setting, which determines the maximum allowed depth for nested structures, can be adjusted using an environment variable. This setting is defined in the `dify_config` module and is used in the `CodeNode` class to enforce the depth limit during code execution. By setting the `CODE_MAX_DEPTH` environment variable, you can increase the maximum depth allowed for your JSON objects <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/configs/feature/__init__.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py)</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/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/3f88d6fb-af3e-400b-a753-13e58112decf?feedback_type=other)</sup>
Author
Owner

@imfeisir commented on GitHub (Feb 6, 2025):

@dosu
I am using Docker compose to deploy and install, where do I modify the dify_config? In docker-compose.yml or .env?

@imfeisir commented on GitHub (Feb 6, 2025): @dosu I am using Docker compose to deploy and install, where do I modify the dify_config? In docker-compose.yml or .env?
Author
Owner

@dosubot[bot] commented on GitHub (Feb 6, 2025):

To modify the CODE_MAX_DEPTH setting when using Docker Compose, you should update the .env file. Add or modify the line with CODE_MAX_DEPTH to set your desired depth limit. For example:

CODE_MAX_DEPTH=10

After updating the .env file, restart your Docker containers to apply the changes:

docker-compose down
docker-compose up -d

This will ensure that the new configuration is loaded.

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 6, 2025): <!-- Answer --> To modify the `CODE_MAX_DEPTH` setting when using Docker Compose, you should update the `.env` file. Add or modify the line with `CODE_MAX_DEPTH` to set your desired depth limit. For example: ```plaintext CODE_MAX_DEPTH=10 ``` After updating the `.env` file, restart your Docker containers to apply the changes: ```bash docker-compose down docker-compose up -d ``` This will ensure that the new configuration is loaded. <!-- 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/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/6423b012-7a53-440a-b111-a6b4c6d39d13?feedback_type=other)</sup>
Author
Owner

@imfeisir commented on GitHub (Feb 6, 2025):

@dosu
Okay, I'll give it a try now, thanks for the guidance!
Additionally, I would like to know if it is possible to have the return value in JSON format in custom tools. What should be noted in the editing content of custom tools? Can an object be returned?

@imfeisir commented on GitHub (Feb 6, 2025): @dosu Okay, I'll give it a try now, thanks for the guidance! Additionally, I would like to know if it is possible to have the return value in JSON format in custom tools. What should be noted in the editing content of custom tools? Can an object be returned?
Author
Owner

@dosubot[bot] commented on GitHub (Feb 6, 2025):

You're welcome! If you encounter any more issues or have further questions, feel free to ask. Good luck with your setup!

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 6, 2025): <!-- Answer --> You're welcome! If you encounter any more issues or have further questions, feel free to ask. Good luck with your setup! <!-- 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/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/cbef7e54-c945-4666-abf3-a041e423e8a4?feedback_type=other)</sup>
Author
Owner

@imfeisir commented on GitHub (Feb 6, 2025):

@dosu
Additionally, I would like to know if it is possible to have the return value in JSON format in custom tools. What should be noted in the editing content of custom tools? Can an object be returned?

@imfeisir commented on GitHub (Feb 6, 2025): @dosu Additionally, I would like to know if it is possible to have the return value in JSON format in custom tools. What should be noted in the editing content of custom tools? Can an object be returned?
Author
Owner

@dosubot[bot] commented on GitHub (Feb 6, 2025):

Yes, it is possible to have the return value in JSON format in custom tools within Dify. You can use the create_json_message method to return a formatted JSON object. This method takes a Python dictionary, which will be automatically serialized into JSON. Here's an example:

def create_json_message(self, json: dict) -> ToolInvokeMessage:
    pass

When editing the content of custom tools, you should define the output variables using the json_schema format to ensure they are properly referenced in the workflow. Here's an example of defining an output variable:

output_schema:
  type: object
  properties:
    name:
      type: string

This schema specifies that the JSON output should be an object with a name field of type string. This setup allows you to return structured JSON objects from your custom tools [1].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 6, 2025): <!-- Answer --> Yes, it is possible to have the return value in JSON format in custom tools within Dify. You can use the `create_json_message` method to return a formatted JSON object. This method takes a Python dictionary, which will be automatically serialized into JSON. Here's an example: ```python def create_json_message(self, json: dict) -> ToolInvokeMessage: pass ``` When editing the content of custom tools, you should define the output variables using the `json_schema` format to ensure they are properly referenced in the workflow. Here's an example of defining an output variable: ```yaml output_schema: type: object properties: name: type: string ``` This schema specifies that the JSON output should be an object with a `name` field of type string. This setup allows you to return structured JSON objects from your custom tools <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/plugins/schema-definition/tool.md)</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/ce64862a-8e9f-4129-9f4e-1737ba12df82?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ce64862a-8e9f-4129-9f4e-1737ba12df82?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ce64862a-8e9f-4129-9f4e-1737ba12df82?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ce64862a-8e9f-4129-9f4e-1737ba12df82?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ce64862a-8e9f-4129-9f4e-1737ba12df82?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/ce64862a-8e9f-4129-9f4e-1737ba12df82?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#8029