Skip to content

Commit b77fabc

Browse files
authored
fix: set timeout as parameter in bash tool (#468)
* fix: set timeout as parameter in bash tool * fix: set timeout as parameter in bash tool
1 parent 2fe1e28 commit b77fabc

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

veadk/tools/skills_tools/bash_tool.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
logger = get_logger(__name__)
2525

2626

27-
async def bash_tool(command: str, description: str, tool_context: ToolContext):
27+
async def bash_tool(
28+
command: str, description: str, tool_context: ToolContext, timeout: float = 600.0
29+
) -> str:
2830
"""Execute bash commands in the skills environment with local shell.
2931
3032
This tool uses the local bash shell to execute commands with:
@@ -57,14 +59,14 @@ async def bash_tool(command: str, description: str, tool_context: ToolContext):
5759
- Use read_file, write_file, and edit_file for interacting with the filesystem.
5860
5961
Timeouts:
60-
- pip install: 120s
61-
- python scripts: 60s
62-
- other commands: 30s
62+
- Default timeout is 600 seconds (10 minutes).
63+
- Adjust the 'timeout' parameter as needed for longer-running commands.
6364
6465
Args:
6566
command: Bash command to execute. Use && to chain commands.
6667
description: Clear, concise description of what this command does (5-10 words)
6768
tool_context: The context of the tool execution, including session info.
69+
timeout: Maximum time in seconds to allow for command execution. Default is 600s.
6870
6971
Returns:
7072
The output of the bash command or error message.
@@ -78,9 +80,6 @@ async def bash_tool(command: str, description: str, tool_context: ToolContext):
7880
working_dir = get_session_path(session_id=tool_context.session.id)
7981
logger.info(f"Session working directory: {working_dir}")
8082

81-
# Determine timeout based on command
82-
timeout = _get_command_timeout_seconds(command)
83-
8483
# Prepare environment with PYTHONPATH including skills directory
8584
# This allows imports like: from skills.slack_gif_creator.core import something
8685
env = os.environ.copy()
@@ -146,13 +145,3 @@ async def bash_tool(command: str, description: str, tool_context: ToolContext):
146145
error_msg = f"Error executing command '{command}': {e}"
147146
logger.error(error_msg)
148147
return error_msg
149-
150-
151-
def _get_command_timeout_seconds(command: str) -> float:
152-
"""Determine appropriate timeout for command in seconds."""
153-
if "pip install" in command or "pip3 install" in command:
154-
return 120.0
155-
elif "python " in command or "python3 " in command:
156-
return 60.0
157-
else:
158-
return 30.0

0 commit comments

Comments
 (0)