From bd8d927f34e97b7e2789957b822bb07111ae3470 Mon Sep 17 00:00:00 2001 From: 0xallam Date: Sun, 7 Dec 2025 15:03:16 +0200 Subject: [PATCH] fix: add timeout to sandbox tool execution HTTP calls Replace timeout=None with configurable timeouts (120s execution, 10s connect) to prevent hung sandbox connections from blocking indefinitely. Configurable via STRIX_SANDBOX_EXECUTION_TIMEOUT and STRIX_SANDBOX_CONNECT_TIMEOUT environment variables. --- strix/tools/executor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/strix/tools/executor.py b/strix/tools/executor.py index 6dd1b04..d99da60 100644 --- a/strix/tools/executor.py +++ b/strix/tools/executor.py @@ -17,6 +17,10 @@ from .registry import ( ) +SANDBOX_EXECUTION_TIMEOUT = float(os.getenv("STRIX_SANDBOX_EXECUTION_TIMEOUT", "120")) +SANDBOX_CONNECT_TIMEOUT = float(os.getenv("STRIX_SANDBOX_CONNECT_TIMEOUT", "10")) + + async def execute_tool(tool_name: str, agent_state: Any | None = None, **kwargs: Any) -> Any: execute_in_sandbox = should_execute_in_sandbox(tool_name) sandbox_mode = os.getenv("STRIX_SANDBOX_MODE", "false").lower() == "true" @@ -62,10 +66,15 @@ async def _execute_tool_in_sandbox(tool_name: str, agent_state: Any, **kwargs: A "Content-Type": "application/json", } + timeout = httpx.Timeout( + timeout=SANDBOX_EXECUTION_TIMEOUT, + connect=SANDBOX_CONNECT_TIMEOUT, + ) + async with httpx.AsyncClient(trust_env=False) as client: try: response = await client.post( - request_url, json=request_data, headers=headers, timeout=None + request_url, json=request_data, headers=headers, timeout=timeout ) response.raise_for_status() response_data = response.json()