{"record":{"id":"570c97b920053b47","repo":"agentscope-ai/agentscope","slug":"ripgrep-search-timed-out-after-timeout-seconds","errorCode":null,"errorMessage":"Ripgrep search timed out after {timeout} seconds. Try searching a more specific path or pattern.","messagePattern":"Ripgrep search timed out after (.+?) seconds\\. Try searching a more specific path or pattern\\.","errorType":"exception","errorClass":"RipgrepTimeoutError","httpStatus":null,"severity":"warning","filePath":"src/agentscope/tool/_builtin/_grep.py","lineNumber":297,"sourceCode":"        search_path: str,\n        timeout: int = 30,\n    ) -> list[str]:\n        \"\"\"Run ripgrep and return output lines.\n\n        Builds an argument vector and dispatches it through\n        ``backend.exec_shell`` (which runs the program directly, without\n        a shell), so the same code path works for local, Docker, and E2B\n        backends and needs no platform-specific argument quoting.\n        \"\"\"\n        command = [\"rg\", *args, search_path]\n\n        result = await self._backend.exec_shell(\n            command,\n            timeout=float(timeout),\n        )\n\n        if result.exit_code == -1 and result.stderr == b\"timed out\":\n            raise RipgrepTimeoutError(\n                f\"Ripgrep search timed out after {timeout} seconds. \"\n                \"Try searching a more specific path or pattern.\",\n                [],\n            )\n\n        # returncode 0 = matches found, 1 = no matches\n        if result.exit_code not in (0, 1):\n            error_msg = result.stderr.decode(\n                \"utf-8\",\n                errors=\"ignore\",\n            ).strip()\n            raise RuntimeError(\n                f\"ripgrep error (code {result.exit_code}): {error_msg}\",\n            )\n\n        raw = result.stdout.decode(\"utf-8\", errors=\"ignore\")\n\n        lines = [","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/tool/_builtin/_grep.py#L279-L315","documentation":"RipgrepTimeoutError raised when the grep tool's shell execution of rg exceeds the requested timeout (exit_code -1, stderr 'timed out'). It carries an empty result list.","triggerScenarios":"GrepTool call over a huge directory tree, broad pattern, or slow filesystem (NFS, node_modules, home dir) with a small timeout value.","commonSituations":"Agents searching '/' or large monorepos; low timeout defaults combined with cold caches or network mounts.","solutions":["Narrow the search path and/or pattern","Increase the timeout argument","Exclude heavy dirs (node_modules, .git, venv) via ripgrep glob excludes","Catch RipgrepTimeoutError and retry with narrower scope"],"exampleFix":"# before\nresults = await grep(pattern='foo', path='/', timeout=10)\n# after\nresults = await grep(pattern='foo', path='src', timeout=60)","handlingStrategy":"retry","validationCode":"import os\nscope_ok = os.path.isdir(path) and path not in ('/', os.path.expanduser('~'))","typeGuard":null,"tryCatchPattern":"try:\n    res = await grep(pattern=pat, path=path, timeout=30)\nexcept RipgrepTimeoutError:\n    res = await grep(pattern=pat, path=shorter_subdir, timeout=120)","preventionTips":["Always pass a scoped path, never '/' or home","Exclude node_modules/.git/venv","Set timeouts proportional to tree size"],"tags":["ripgrep","timeout","search","tool"],"backgroundTag":"search-timeout","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}