mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
fix(agent): align Binding file upload timeouts (#41027)
This commit is contained in:
1 parent
785ca4b915
commit
0ca99312c1
20 files changed
+154
-21
No files matched your search
@@ -52,7 +52,6 @@ from dify_agent.protocol import (
|
||||
_ResponseModelT = TypeVar("_ResponseModelT", bound=BaseModel)
|
||||
_TERMINAL_EVENT_TYPES = {"run_succeeded", "run_failed", "run_cancelled"}
|
||||
_TERMINAL_RUN_STATUSES = {"succeeded", "failed", "cancelled"}
|
||||
_BINDING_FILE_DOWNLOAD_TIMEOUT_SECONDS = 90.0
|
||||
_function_tool_result_payload_key_cache: str | None = None
|
||||
|
||||
|
||||
@@ -271,6 +270,7 @@ class Client:
|
||||
_base_url: str
|
||||
_timeout: float | httpx.Timeout
|
||||
_stream_timeout: float | httpx.Timeout | None
|
||||
_binding_file_download_timeout: float | httpx.Timeout
|
||||
_headers: dict[str, str]
|
||||
_sync_http_client: httpx.Client | None
|
||||
_async_http_client: httpx.AsyncClient | None
|
||||
@@ -285,6 +285,7 @@ class Client:
|
||||
base_url: str,
|
||||
timeout: float | httpx.Timeout = 30.0,
|
||||
stream_timeout: float | httpx.Timeout | None = 30.0,
|
||||
binding_file_download_timeout: float | httpx.Timeout = 240.0,
|
||||
headers: dict[str, str] | None = None,
|
||||
sync_http_client: httpx.Client | None = None,
|
||||
async_http_client: httpx.AsyncClient | None = None,
|
||||
@@ -292,6 +293,7 @@ class Client:
|
||||
self._base_url = base_url.rstrip("/")
|
||||
self._timeout = timeout
|
||||
self._stream_timeout = stream_timeout
|
||||
self._binding_file_download_timeout = binding_file_download_timeout
|
||||
self._headers = dict(headers or {})
|
||||
self._sync_http_client = sync_http_client
|
||||
self._async_http_client = async_http_client
|
||||
@@ -549,7 +551,7 @@ class Client:
|
||||
"download_binding_file",
|
||||
"/execution-bindings/files/download",
|
||||
request,
|
||||
timeout=_BINDING_FILE_DOWNLOAD_TIMEOUT_SECONDS,
|
||||
timeout=self._binding_file_download_timeout,
|
||||
)
|
||||
return _parse_model_response(response, BindingFileDownloadResponse)
|
||||
|
||||
@@ -558,7 +560,7 @@ class Client:
|
||||
"download_binding_file_sync",
|
||||
"/execution-bindings/files/download",
|
||||
request,
|
||||
timeout=_BINDING_FILE_DOWNLOAD_TIMEOUT_SECONDS,
|
||||
timeout=self._binding_file_download_timeout,
|
||||
)
|
||||
return _parse_model_response(response, BindingFileDownloadResponse)
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ def create_app(settings: ServerSettings | None = None) -> FastAPI:
|
||||
execution_bindings=runtime_backend_profile.execution_bindings,
|
||||
agent_stub_api_base_url=resolved_settings.agent_stub_api_base_url,
|
||||
agent_stub_token_factory=agent_stub_token_factory,
|
||||
download_command_timeout_seconds=resolved_settings.binding_file_download_command_timeout_seconds,
|
||||
)
|
||||
if runtime_backend_profile is not None
|
||||
else None
|
||||
|
||||
@@ -39,7 +39,6 @@ logger = logging.getLogger(__name__)
|
||||
_LIST_MAX_ENTRIES = 1000
|
||||
_BROWSE_TIMEOUT_SECONDS = 60.0
|
||||
_BROWSE_OUTPUT_MAX_BYTES = 1024 * 1024
|
||||
_DOWNLOAD_TIMEOUT_SECONDS = 60.0
|
||||
_DOWNLOAD_OUTPUT_MAX_BYTES = 32 * 1024
|
||||
_PAYLOAD_BEGIN = "<<<DIFY_BINDING_FILE_BEGIN>>>"
|
||||
_PAYLOAD_END = "<<<DIFY_BINDING_FILE_END>>>"
|
||||
@@ -149,6 +148,7 @@ class BindingFileService:
|
||||
execution_bindings: ExecutionBindingBackend
|
||||
agent_stub_api_base_url: str | None
|
||||
agent_stub_token_factory: ShellAgentStubTokenFactory | None
|
||||
download_command_timeout_seconds: float
|
||||
|
||||
async def list_files(self, request: BindingFileListRequest) -> BindingFileListResponse:
|
||||
try:
|
||||
@@ -243,7 +243,7 @@ class BindingFileService:
|
||||
f"dify-agent file upload --no-download-link {shlex.quote(resolved_path)}",
|
||||
cwd=lease.layout.workspace_dir,
|
||||
env=env,
|
||||
timeout=_DOWNLOAD_TIMEOUT_SECONDS,
|
||||
timeout=self.download_command_timeout_seconds,
|
||||
max_output_bytes=_DOWNLOAD_OUTPUT_MAX_BYTES,
|
||||
mode="stdio",
|
||||
)
|
||||
|
||||
@@ -82,6 +82,7 @@ class ServerSettings(BaseSettings):
|
||||
description="Maximum Agent Stub upload size in MiB",
|
||||
validation_alias="DIFY_AGENT_STUB_UPLOAD_FILE_SIZE_LIMIT",
|
||||
)
|
||||
binding_file_download_command_timeout_seconds: float = Field(default=210.0, gt=0)
|
||||
server_secret_key: str | None = None
|
||||
api_token: str | None = None
|
||||
shell_redact_patterns: str = ""
|
||||
|
||||
Reference in new issue
Block a user