π OpenHands: AI-Driven Development
Better timeout prompt (#9140)
Graham Neubig035050252bb5
diff --git a/openhands/agenthub/codeact_agent/tools/bash.py b/openhands/agenthub/codeact_agent/tools/bash.pyindex 5f890fc559..3dc39c7c65 100644--- a/openhands/agenthub/codeact_agent/tools/bash.py+++ b/openhands/agenthub/codeact_agent/tools/bash.py@@ -6,17 +6,20 @@ from openhands.llm.tool_names import EXECUTE_BASH_TOOL_NAME_DETAILED_BASH_DESCRIPTION = """Execute a bash command in the terminal within a persistent shell session.+### Command Execution* 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.* Persistent session: Commands execute in a persistent shell session where environment variables, virtual environments, and working directory persist between commands.-* 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)+* 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)-### Running and Interacting with Processes-* 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.-* 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:+### 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 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.+* 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:- Send empty `command` to retrieve additional logs- Send text (set `command` to the text) to STDIN of the running process- Send control commands like `C-c` (Ctrl+C), `C-d` (Ctrl+D), or `C-z` (Ctrl+Z) to interrupt the process+ - If you do C-c, you can re-start the process with a longer "timeout" parameter to let it run to completion### Best Practices* Directory verification: Before creating new directories or files, first verify the parent directory exists and is the correct location.