Skip to content

Commit 940c9c5

Browse files
committed
Better timeout commands
1 parent a93b045 commit 940c9c5

File tree

1 file changed

+7
-4
lines changed
  • openhands/agenthub/codeact_agent/tools

1 file changed

+7
-4
lines changed

openhands/agenthub/codeact_agent/tools/bash.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66

77
_DETAILED_BASH_DESCRIPTION = """Execute a bash command in the terminal within a persistent shell session.
88
9+
910
### Command Execution
1011
* One command at a time: You can only execute one bash command at a time. If you need to run multiple commands sequentially, use `&&` or `;` to chain them together.
1112
* Persistent session: Commands execute in a persistent shell session where environment variables, virtual environments, and working directory persist between commands.
12-
* Timeout: Commands have a soft timeout of 10 seconds, once that's reached, you have the option to continue or interrupt the command (see section below for details)
13+
* Soft timeout: Commands have a soft timeout of 10 seconds, once that's reached, you have the option to continue or interrupt the command (see section below for details)
1314
14-
### Running and Interacting with Processes
15-
* Long running commands: For commands that may run indefinitely, run them in the background and redirect output to a file, e.g. `python3 app.py > server.log 2>&1 &`. For commands that need to run for a specific duration, like "sleep", you can set the "timeout" argument to specify a hard timeout in seconds.
16-
* Interact with running process: If a bash command returns exit code `-1`, this means the process is not yet finished. By setting `is_input` to `true`, you can:
15+
### Long-running Commands
16+
* For commands that may run indefinitely, run them in the background and redirect output to a file, e.g. `python3 app.py > server.log 2>&1 &`.
17+
* For commands that may run for a long time (e.g. installation or testing commands), or commands that run for a fixed amount of time (e.g. sleep), you should set the "timeout" parameter of your function call to an appropriate value.
18+
* If a bash command returns exit code `-1`, this means the process hit the soft timeout and is not yet finished. By setting `is_input` to `true`, you can:
1719
- Send empty `command` to retrieve additional logs
1820
- Send text (set `command` to the text) to STDIN of the running process
1921
- Send control commands like `C-c` (Ctrl+C), `C-d` (Ctrl+D), or `C-z` (Ctrl+Z) to interrupt the process
22+
- If you do C-c, you can re-start the process with a longer "timeout" parameter to let it run to completion
2023
2124
### Best Practices
2225
* Directory verification: Before creating new directories or files, first verify the parent directory exists and is the correct location.

0 commit comments

Comments
 (0)