From 3b90fa5c9ba5821ac3ce85d8607b4b346f6ec9c7 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Fri, 20 Feb 2026 01:29:53 -0800 Subject: [PATCH] fix: increase default timeout for code execution sandbox - Updated the default timeout for sandbox script execution from 120 seconds to 300 seconds (5 minutes) to allow longer-running scripts. - Enhanced comments in the code execution tool to clarify the timeout duration. - Suppressed stdout and stderr output from internal tool handlers during execution to prevent clutter in the CLI interface. --- cli.py | 2 +- tools/code_execution_tool.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cli.py b/cli.py index 06fb1127..65daaad5 100755 --- a/cli.py +++ b/cli.py @@ -136,7 +136,7 @@ def load_cli_config() -> Dict[str, Any]: "timeout": 120, # Seconds to wait for a clarify answer before auto-proceeding }, "code_execution": { - "timeout": 120, # Max seconds a sandbox script can run before being killed + "timeout": 300, # Max seconds a sandbox script can run before being killed (5 min) "max_tool_calls": 50, # Max RPC tool calls per execution }, } diff --git a/tools/code_execution_tool.py b/tools/code_execution_tool.py index 0055eac7..0bbecd34 100644 --- a/tools/code_execution_tool.py +++ b/tools/code_execution_tool.py @@ -46,7 +46,7 @@ SANDBOX_ALLOWED_TOOLS = frozenset([ ]) # Resource limit defaults (overridable via config.yaml → code_execution.*) -DEFAULT_TIMEOUT = 120 # seconds +DEFAULT_TIMEOUT = 300 # 5 minutes DEFAULT_MAX_TOOL_CALLS = 50 MAX_STDOUT_BYTES = 50_000 # 50 KB MAX_STDERR_BYTES = 10_000 # 10 KB @@ -255,11 +255,21 @@ def _rpc_server_loop( for param in _TERMINAL_BLOCKED_PARAMS: tool_args.pop(param, None) - # Dispatch through the standard tool handler + # Dispatch through the standard tool handler. + # Suppress stdout/stderr from internal tool handlers so + # their status prints don't leak into the CLI spinner. try: - result = handle_function_call( - tool_name, tool_args, task_id=task_id - ) + _real_stdout, _real_stderr = sys.stdout, sys.stderr + sys.stdout = open(os.devnull, "w") + sys.stderr = open(os.devnull, "w") + try: + result = handle_function_call( + tool_name, tool_args, task_id=task_id + ) + finally: + sys.stdout.close() + sys.stderr.close() + sys.stdout, sys.stderr = _real_stdout, _real_stderr except Exception as exc: result = json.dumps({"error": str(exc)})