← Back to PRs

#6362: fix(memory): add ignore patterns to chokidar file watcher

by Glucksberg open 2026-02-01 15:35 View on GitHub →
agents size: S experienced-contributor
## Summary Adds `ignorePaths` config option to memorySearch that prevents chokidar from watching non-document directories. ## Problem When `memorySearch.extraPaths` points to a directory containing large non-document subtrees (e.g., Python `.venv` with PyTorch, `node_modules`, `.git`), chokidar opens a file descriptor for **every file and directory** in the tree — even though only `.md` files are ever indexed. This causes the gateway process to exhaust its file descriptor limit and produce: ``` spawn EBADF Error: EMFILE: too many open files ``` ## Solution 1. Add `ignorePaths` array to memorySearch config (zod schema, types, etc) 2. Add default ignore patterns: `node_modules`, `.git`, `.venv`, `venv`, `.env`, `__pycache__`, `.tox`, `dist`, `build`, `.next`, `.nuxt`, `target`, `.cargo` 3. Pass `ignored` option to chokidar.watch() 4. Update `listMemoryFiles()` and `walkDir()` to respect ignore patterns ## Config Example ```json { "agents": { "defaults": { "memorySearch": { "extraPaths": ["/large/project"], "ignorePaths": ["**/custom_ignore/**"] } } } } ``` ## Testing Added test for `listMemoryFiles()` with ignorePaths. Closes #5827 Re-opens fix from #6146 (incorrectly closed by triage bot) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds an `ignorePaths` option to `memorySearch` and wires it through config/schema/types, then uses it to reduce file watcher scope (via chokidar’s `ignored` option) and to skip ignored directories when enumerating memory markdown files. Main concern: `ignorePaths` is documented and surfaced as “glob patterns”, but `listMemoryFiles()` only implements a narrow subset (extracting literal dir names from patterns like `**/dirname/**`). Since chokidar applies full glob semantics, certain ignore patterns can lead to watch/index mismatches or silently not be honored during indexing. <h3>Confidence Score: 3/5</h3> - Mostly safe to merge, but the ignorePaths behavior is inconsistent and may surprise users. - The change is localized and addresses a real resource issue, but the new ignorePaths setting is described as glob patterns while indexing only supports a narrow pattern shape, and chokidar uses full glob semantics—creating potential watch/index divergence and confusing configs. - src/memory/internal.ts, src/memory/manager.ts, src/agents/memory-search.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs