Skip to content

Feat/dify integration#157

Open
hittyt wants to merge 2 commits intoalibaba:mainfrom
hittyt:feat/dify-integration
Open

Feat/dify integration#157
hittyt wants to merge 2 commits intoalibaba:mainfrom
hittyt:feat/dify-integration

Conversation

@hittyt
Copy link
Collaborator

@hittyt hittyt commented Feb 1, 2026

Summary

This PR introduces a Dify plugin that enables Dify workflows to use OpenSandbox as a code execution environment.
Features

Three sandbox tools for Dify workflows:

  • sandbox_create - Create a new sandbox with configurable image, timeout, and environment
  • sandbox_run - Execute commands in a running sandbox
  • sandbox_kill - Terminate a sandbox

Flexible credential management:

  • Supports Dify's built-in credential configuration
  • Falls back to environment variables (OPENSANDBOX_BASE_URL, OPENSANDBOX_API_KEY)

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

@jwx0925
Copy link
Collaborator

jwx0925 commented Feb 1, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 908726f4b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 20 to 24
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
base_url = credentials.get("opensandbox_base_url", "")
api_key = credentials.get("opensandbox_api_key", "")
if not base_url or not api_key:
raise ToolProviderCredentialValidationError("Missing OpenSandbox base URL or API key.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow env fallback during credential validation

The tools support falling back to OPENSANDBOX_BASE_URL/OPENSANDBOX_API_KEY, but the provider validation rejects missing credentials before tools ever run. In Dify, provider validation happens when configuring the plugin, so a deployment that relies on env vars (e.g., secrets injected into the runtime container) will fail to register the provider even though build_connection_config would succeed at invocation time. If env-only configuration is intended, this should read env vars here or mark the credentials optional in the provider definition so the plugin can be used with env-based configuration.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add env recognition support for the fallback path

@hittyt hittyt added the feature New feature or request label Feb 1, 2026
@Pangjiping
Copy link
Collaborator

@ninan-nn please review this about Python sdk usage

# uv pip compile pyproject.toml -o ./requirements.txt
dependencies = [
"dify-plugin>=0.5.1",
"opensandbox",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the dependency version range to opensandbox>=1.0.0,<2.0.0 to avoid unexpected breaking changes from future major releases and ensure compatibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion! Added opensandbox>=0.1.0,<0.2.0 to ensure compatibility.

# See the License for the specific language governing permissions and
# limitations under the License.

[project]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested: use Pyright and Ruff for type checking and linting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I had depended ruff already.
Since it's just a MVP dify plugin and is not stable, I believe we do NOT introduce Pyright now for simplicity.

en_US: API key for OpenSandbox server authentication. Falls back to OPENSANDBOX_API_KEY env var.
zh_Hans: 用于 OpenSandbox 服务鉴权的 API Key。如未填写,将使用 OPENSANDBOX_API_KEY 环境变量。
tools:
- tools/sandbox_create.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why filesystem tool not provided, eg. file_read & file_write

@hittyt hittyt force-pushed the feat/dify-integration branch from 00b6eec to 05a5978 Compare March 1, 2026 06:31
- Add OpenSandbox Dify plugin with sandbox_create, sandbox_run, sandbox_kill tools
- Add E2E test framework for Dify plugin integration
- Add GitHub Actions workflow for automated E2E testing
- Support both local testing and CI testing
- Use stable Dify release tag 1.11.4
- Add Docker image caching to speed up E2E tests
- Add unit tests for plugin tools
- Add Apache 2.0 license headers
- Use OpenSandbox own icon
@hittyt hittyt force-pushed the feat/dify-integration branch from 67a9d99 to a68b919 Compare March 1, 2026 06:40
Align Dify plugin E2E image build with other E2E workflows by using the repository root as Docker build context. This avoids missing file errors for components referenced via COPY in components/execd/Dockerfile.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants