From bcdb0e25583e178b6ad12a4742854790b6a1b5bf Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Wed, 15 Oct 2025 20:01:17 +0500 Subject: [PATCH] Fix timeout handling for zero-millisecond values Previously, when `timeout_ms` was explicitly set to `0`, the condition `if args.timeout_ms` evaluated to `False` (since `0` is falsy), causing the timeout to be treated as `None` (no timeout). This violated the intended behavior where `0` should mean "time out immediately." The fix changes the check to `if args.timeout_ms is not None`, ensuring that: - `timeout_ms=0` correctly results in a `0.0` second timeout - `timeout_ms=None` (or unset) still results in no timeout - All other positive values work as before This aligns the implementation with standard `subprocess.run()` timeout semantics and prevents unintended indefinite command execution. --- examples/tools/local_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tools/local_shell.py b/examples/tools/local_shell.py index 0c63fad6e..e9cf2e5fa 100644 --- a/examples/tools/local_shell.py +++ b/examples/tools/local_shell.py @@ -15,7 +15,7 @@ def shell_executor(request: LocalShellCommandRequest) -> str: env={**os.environ, **args.env} if args.env else os.environ, capture_output=True, text=True, - timeout=(args.timeout_ms / 1000) if args.timeout_ms else None, + timeout=(args.timeout_ms / 1000) if args.timeout_ms is not None else None, ) return completed.stdout + completed.stderr