mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 02:15:22 -04:00
[PR #208] [MERGED] feat: add max_invocation_timeout parameter #221
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/208
Author: @Bytechoreographer
Created: 9/23/2025
Status: ✅ Merged
Merged: 9/26/2025
Merged by: @Yeuoly
Base:
main← Head:feat/invocation_timeout_config📝 Commits (2)
cdc8492feat: add max_invocation_timeout parameterd98b081style: format MAX_INVOCATION_TIMEOUT description for better readability📊 Changes
3 files changed (+15 additions, -4 deletions)
View changed files
📝
python/dify_plugin/config/config.py(+3 -0)📝
python/dify_plugin/core/runtime.py(+11 -4)📝
python/dify_plugin/plugin.py(+1 -0)📄 Description
Plugin Invocation Timeout Configuration
Problem
Previously, the Dify Plugin SDK had a hardcoded timeout of 250 seconds for backwards invocations. When a plugin operation took longer than 250 seconds without receiving any response data, it would throw an exception:
This limitation affected plugins that needed to perform long-running operations such as:
Solution
We've introduced a configurable timeout mechanism that allows developers to customize the invocation timeout based on their specific needs.
New Configuration Parameter
A new configuration parameter
MAX_INVOCATION_TIMEOUThas been added toDifyPluginEnv:How It Works
Configurable Timeout: Instead of the hardcoded 250-second limit, the system now uses the
MAX_INVOCATION_TIMEOUTvalue from the configuration.Per-Plugin Configuration: Each plugin can set its own timeout value when initializing the
DifyPluginEnv.Backwards Compatibility: The default value is 250 seconds, which is higher than the previous hardcoded 250 seconds, providing better default behavior.
Dynamic Error Messages: Error messages now include the actual timeout value used for better debugging.
Usage Examples
Basic Usage with Custom Timeout
Environment Variable Configuration
You can also set the timeout via environment variables:
Different Scenarios
Technical Details
Implementation Changes
MAX_INVOCATION_TIMEOUTtoDifyPluginEnvclassSessionclass to accept and store the timeout value_line_converter_wrappermethod to use dynamic timeoutPluginclass to pass the configuration to sessionsTimeout Logic
The timeout mechanism works as follows:
MAX_INVOCATION_TIMEOUT, the operation times outError Handling
When a timeout occurs, the system now provides more informative error messages:
Migration Guide
For Existing Plugins
Existing plugins will continue to work without changes.
For New Plugins
New plugins can explicitly set their timeout requirements:
Best Practices
Related Configuration
The timeout configuration works alongside other timeout settings:
MAX_REQUEST_TIMEOUT: HTTP request timeout (default: 250s)MAX_INVOCATION_TIMEOUT: Backwards invocation timeout (default: 250s)Both can be configured independently based on your plugin's needs.
Pull Request Checklist
Thank you for your contribution! Before submitting your PR, please make sure you have completed the following checks:
Compatibility Check
README.mdREADME.mdREADME.mdREADME.mdAvailable Checks
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.