{"record":{"id":"9e5f7c1bdcd792e2","repo":"FoundationAgents/OpenManus","slug":"command-cmd-timed-out-after-timeout-seconds-9e5f7c","errorCode":null,"errorMessage":"Command '{cmd}' timed out after {timeout} seconds in sandbox","messagePattern":"Command '(.+?)' timed out after (.+?) seconds in sandbox","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"app/tool/file_operators.py","lineNumber":154,"sourceCode":"        )\n        return result.strip() == \"true\"\n\n    async def run_command(\n        self, cmd: str, timeout: Optional[float] = 120.0\n    ) -> Tuple[int, str, str]:\n        \"\"\"Run a command in sandbox environment.\"\"\"\n        await self._ensure_sandbox_initialized()\n        try:\n            stdout = await self.sandbox_client.run_command(\n                cmd, timeout=int(timeout) if timeout else None\n            )\n            return (\n                0,  # Always return 0 since we don't have explicit return code from sandbox\n                stdout,\n                \"\",  # No stderr capture in the current sandbox implementation\n            )\n        except TimeoutError as exc:\n            raise TimeoutError(\n                f\"Command '{cmd}' timed out after {timeout} seconds in sandbox\"\n            ) from exc\n        except Exception as exc:\n            return 1, \"\", f\"Error executing command in sandbox: {str(exc)}\"\n","sourceCodeStart":136,"sourceCodeEnd":159,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/tool/file_operators.py#L136-L159","documentation":"Raised by SandboxFileOperator.run_command (app/tool/file_operators.py:154) when the sandbox client raises TimeoutError executing a command. The default timeout is 120.0 seconds; the wrapper re-raises a new TimeoutError with the command text and the timeout value, chaining the original. All other exceptions degrade to a (1, '', 'Error executing command...') return value instead of raising.","triggerScenarios":"Calling run_command(cmd, timeout=N) (or omitting timeout, defaulting to 120s) where the command runs longer than the timeout: package installs (pip/npm), long builds, test suites, or commands that block waiting for input. Also triggered when timeout is passed as a falsy-but-non-None value, since `int(timeout) if timeout else None` disables the client timeout only for falsy values.","commonSituations":"CI/agent loops running `npm install` or `pytest` in a sandbox with the 120s default; commands that prompt interactively (apt-get without -y) and never terminate; overloaded sandbox hosts making trivial commands exceed the budget; forgetting to pass a larger timeout for known-slow steps.","solutions":["Pass an explicit larger timeout: `await operator.run_command(cmd, timeout=600)`.","Make the command non-interactive and bounded: add flags like `-y`, `--no-input`, `--max-time`, or `timeout 600 <cmd> && echo done` inside the command itself.","For unbounded work, background it and poll: `nohup <cmd> > /tmp/log 2>&1 & echo $!` then check the log/process with subsequent run_command calls.","Catch TimeoutError at the call site (it propagates as a real TimeoutError, not ToolError) and decide whether to retry, extend, or abort."],"exampleFix":"// before\nrc, out, err = await sandbox_files.run_command('npm install')  # 120s default, times out\n\n// after\nrc, out, err = await sandbox_files.run_command('npm install --no-audit --no-fund', timeout=600)","handlingStrategy":"try-catch","validationCode":"timeout = timeout if timeout is not None else 120\n# budget the call: run only commands you expect to finish well under `timeout`","typeGuard":"def has_bounded_timeout(cmd: str, timeout: float | None, expected_secs: int) -> bool:\n    return timeout is not None and timeout >= expected_secs * 1.5 and '<' not in cmd","tryCatchPattern":"try:\n    rc, out, err = await sandbox_files.run_command(cmd, timeout=600)\nexcept TimeoutError:\n    rc, out, err = 1, '', f'{cmd} exceeded budget; consider backgrounding'","preventionTips":["Always pass an explicit timeout sized to the command (installs/builds: 300-900s).","Make commands non-interactive (-y, --no-input) so they cannot hang waiting for stdin.","Background long jobs (nohup ... &) and poll their log instead of blocking run_command."],"tags":["sandbox","timeout","command-execution","async"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}