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.
This commit is contained in:
parent
273b367f05
commit
3b90fa5c9b
2 changed files with 16 additions and 6 deletions
2
cli.py
2
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
|
"timeout": 120, # Seconds to wait for a clarify answer before auto-proceeding
|
||||||
},
|
},
|
||||||
"code_execution": {
|
"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
|
"max_tool_calls": 50, # Max RPC tool calls per execution
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ SANDBOX_ALLOWED_TOOLS = frozenset([
|
||||||
])
|
])
|
||||||
|
|
||||||
# Resource limit defaults (overridable via config.yaml → code_execution.*)
|
# Resource limit defaults (overridable via config.yaml → code_execution.*)
|
||||||
DEFAULT_TIMEOUT = 120 # seconds
|
DEFAULT_TIMEOUT = 300 # 5 minutes
|
||||||
DEFAULT_MAX_TOOL_CALLS = 50
|
DEFAULT_MAX_TOOL_CALLS = 50
|
||||||
MAX_STDOUT_BYTES = 50_000 # 50 KB
|
MAX_STDOUT_BYTES = 50_000 # 50 KB
|
||||||
MAX_STDERR_BYTES = 10_000 # 10 KB
|
MAX_STDERR_BYTES = 10_000 # 10 KB
|
||||||
|
|
@ -255,11 +255,21 @@ def _rpc_server_loop(
|
||||||
for param in _TERMINAL_BLOCKED_PARAMS:
|
for param in _TERMINAL_BLOCKED_PARAMS:
|
||||||
tool_args.pop(param, None)
|
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:
|
try:
|
||||||
result = handle_function_call(
|
_real_stdout, _real_stderr = sys.stdout, sys.stderr
|
||||||
tool_name, tool_args, task_id=task_id
|
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:
|
except Exception as exc:
|
||||||
result = json.dumps({"error": str(exc)})
|
result = json.dumps({"error": str(exc)})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue