Reintroduce advance dependencies in Code Node while using Python3 #19805

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

Originally created by @Tomahawkd on GitHub (Oct 21, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Currently users have to configure python-requirement.txt in sandbox to add custom dependencies before the sandbox startup. This is very inconvinient for users to add dependencies for their workflow especially when the user needs a new dependency. They have to shut down the sandbox, add dependencies to python-requirement.txt and finally restart the sandbox. You can refer current sandbox dependency management implementation here.

My proposal is reintroduce advanced dependencies. I'm not trying to revert https://github.com/langgenius/dify/pull/7494, but let users to add more dependencies based on current. The full step is as follows:

  1. The user adds dependencies from web interface, such as:
    Image

  2. The api service post a request to sandbox service with following data:

{
    "language": "python3",
    "code": "xxx",
    "preload": "xxx",
    "enable_network": true, // this always true from api service
    "dependencies": [{"name": "pyyaml", "version": ""}] // My proposal
}
  1. The sandbox service detects if there is custom dependencies. If not, run the code using current implementation. Otherwise, the sandbox will use uv to create a virtual environment and install dependencies. You can checkout my changes on sanbox: https://github.com/langgenius/dify-sandbox/pull/190

2. Additional context or comments

Some discussion on user interface: I found there is a dependency picker which is used to select dependency. Maybe we can reuse this to help the user to search dependencies. I tried to use https://pypi.org/simple/ (don't open it, it is very big) to collect and search dependencies but it will make UI laggy. Perhaps there is some search API we can use (but I haven't discovered one).

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @Tomahawkd on GitHub (Oct 21, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Currently users have to configure `python-requirement.txt` in sandbox to add custom dependencies before the sandbox startup. This is very inconvinient for users to add dependencies for their workflow especially when the user needs a new dependency. They have to shut down the sandbox, add dependencies to `python-requirement.txt` and finally restart the sandbox. You can refer current sandbox dependency management implementation [here](https://github.com/langgenius/dify-sandbox/blob/main/internal/core/runner/python/setup.go#L96). My proposal is reintroduce advanced dependencies. I'm not trying to revert [https://github.com/langgenius/dify/pull/7494](https://github.com/langgenius/dify/pull/7494), but let users to add more dependencies based on current. The full step is as follows: 1. The user adds dependencies from web interface, such as: <img width="382" height="319" alt="Image" src="https://github.com/user-attachments/assets/6b00c181-4a01-4455-9e60-aa3ab0d14588" /> 2. The api service post a request to sandbox service with following data: ```json { "language": "python3", "code": "xxx", "preload": "xxx", "enable_network": true, // this always true from api service "dependencies": [{"name": "pyyaml", "version": ""}] // My proposal } ``` 3. The sandbox service detects if there is custom dependencies. If not, run the code using current implementation. Otherwise, the sandbox will use `uv` to create a virtual environment and install dependencies. You can checkout my changes on sanbox: [https://github.com/langgenius/dify-sandbox/pull/190](https://github.com/langgenius/dify-sandbox/pull/190) ### 2. Additional context or comments Some discussion on user interface: I found there is a [dependency picker](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/code/dependency-picker.tsx) which is used to select dependency. Maybe we can reuse this to help the user to search dependencies. I tried to use [https://pypi.org/simple/](https://pypi.org/simple/) (don't open it, it is very big) to collect and search dependencies but it will make UI laggy. Perhaps there is some search API we can use (but I haven't discovered one). ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 20:04:12 -05:00
yindo closed this issue 2026-02-21 20:04:12 -05:00
Author
Owner

@Tomahawkd commented on GitHub (Oct 21, 2025):

You can find my preliminary changes here: https://github.com/Tomahawkd/dify/commit/e18623efd6dca99e50ea8d171a0e4362bc1181d7

@Tomahawkd commented on GitHub (Oct 21, 2025): You can find my preliminary changes here: [https://github.com/Tomahawkd/dify/commit/e18623efd6dca99e50ea8d171a0e4362bc1181d7](https://github.com/Tomahawkd/dify/commit/e18623efd6dca99e50ea8d171a0e4362bc1181d7)
Author
Owner

@dosubot[bot] commented on GitHub (Oct 21, 2025):

Hi @Tomahawkd! I'm Dosu and I’m helping the dify team.

Thanks for sharing your preliminary changes and your interest in contributing! Your approach to reintroducing advanced dependency management for Python3 code nodes—using a dependencies field in the API payload and leveraging uv for dynamic installation—aligns well with Dify's ongoing migration to uv for Python dependency management, which aims to improve runtime performance and flexibility source.

Reusing the dependency-picker component for UI selection is a solid idea, and your observation about PyPI search performance is valid; integrating a more efficient search API would be a useful enhancement source.

One thing to watch for is ensuring the sandbox sets the correct working directory and environment variables when invoking uv, as this has caused issues in related plugin environments source.

If you have specific questions or want feedback on particular parts of your implementation, let me know! Your work is well aligned with current best practices and migration efforts in the main repo.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 21, 2025): <!-- Greeting --> Hi @Tomahawkd! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> Thanks for sharing your preliminary changes and your interest in contributing! Your approach to reintroducing advanced dependency management for Python3 code nodes—using a `dependencies` field in the API payload and leveraging `uv` for dynamic installation—aligns well with Dify's ongoing migration to uv for Python dependency management, which aims to improve runtime performance and flexibility [source](https://github.com/langgenius/dify/issues/16305). Reusing the dependency-picker component for UI selection is a solid idea, and your observation about PyPI search performance is valid; integrating a more efficient search API would be a useful enhancement [source](https://github.com/langgenius/dify/blob/845adb664a7999ee8fbc11bd36c9f576b35ad237/web/app/components/workflow/nodes/code/dependency-picker.tsx). One thing to watch for is ensuring the sandbox sets the correct working directory and environment variables when invoking `uv`, as this has caused issues in related plugin environments [source](https://github.com/langgenius/dify/issues/19522). If you have specific questions or want feedback on particular parts of your implementation, let me know! Your work is well aligned with current best practices and migration efforts in the main repo. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/52c654bc-f0bc-473b-ad51-4c4b3b5f9a66?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/27239)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#19805