Skip to content

Commit 0b25afd

Browse files
committed
new: increased shell namespace default timeout to 60 seconds and introduced NERVE_SHELL_TIMEOUT env variable to override it (closes #56)
1 parent a5ede67 commit 0b25afd

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/namespaces.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ Let the agent execute shell commands.
278278

279279
### `shell`
280280

281-
<pre>Execute a shell command on the local computer and return the output. Non interactive shell with a timeout of 30 seconds.</pre>
281+
<pre>Execute a shell command on the local computer and return the output. Non interactive shell with a timeout of 60 seconds.</pre>
282+
283+
> [!TIP]
284+
> The default timeout for shell commands is 60 seconds. You can override this value by setting the `NERVE_SHELL_TIMEOUT` environment variable.
282285

283286
**Parameters**
284287

nerve/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
DEFAULT_MAX_STEPS: int = int(os.getenv("NERVE_MAX_STEPS", 100))
88
DEFAULT_MAX_COST: float = float(os.getenv("NERVE_MAX_COST", 10.0))
99
DEFAULT_TIMEOUT: int | None = int(os.getenv("NERVE_TIMEOUT", 0)) or None
10+
DEFAULT_SHELL_TIMEOUT: int = int(os.getenv("NERVE_SHELL_TIMEOUT", "60"))
1011
DEFAULT_CONVERSATION_STRATEGY: str = os.getenv("NERVE_CONVERSATION_STRATEGY", "full")
1112

1213
DEFAULT_NERVE_HOME: pathlib.Path = pathlib.Path.home() / ".nerve"

nerve/tools/namespaces/shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
from typing import Annotated
1010

11+
from nerve.defaults import DEFAULT_SHELL_TIMEOUT
1112
from nerve.tools.utils import maybe_text
1213

1314
# for docs
@@ -19,7 +20,7 @@ def shell(
1920
) -> str | bytes:
2021
"""Execute a shell command on the local computer and return the output. Non interactive shell with a timeout of 30 seconds."""
2122

22-
result = subprocess.run(command, shell=True, capture_output=True, timeout=30)
23+
result = subprocess.run(command, shell=True, capture_output=True, timeout=DEFAULT_SHELL_TIMEOUT)
2324

2425
raw_output = result.stdout or b""
2526

0 commit comments

Comments
 (0)