When --watch auto is enabled on a folder that contains the .agent-brain/ directory (i.e. the project root), the file watcher enters an infinite loop:
- A job completes → writes to .agent-brain/logs/server.err and .agent-brain/jobs/
- watchfiles detects those writes as file changes
- A new job is enqueued → completes as a no-op ("all files unchanged")
- Repeat forever — server stays permanently in INDEXING state
Root cause
AgentBrainWatchFilter in file_watcher_service.py uses a hardcoded ignore_dirs list that does not include .agent-brain/. The exclude_patterns from config.json are passed to the document loader only — they are not forwarded to watchfiles.awatch().
Expected behavior
.agent-brain/ should be excluded from the file watcher, either by adding it to AgentBrainWatchFilter.ignore_dirs or by passing config exclude_patterns dynamically to watchfiles.awatch().
Suggested fixes
- Add .agent-brain to the hardcoded ignore_dirs in AgentBrainWatchFilter:
ignore_dirs = {*DefaultFilter.ignore_dirs, "dist", "build", ".next", ".agent-brain"}
- More broadly, consider reading the project's .gitignore and applying those patterns to the file watcher as well (AND to indexer too). Projects already declare what should be ignored there, and respecting it would prevent this class of issue for any similar directories (e.g. .turbo, .parcel-cache, .svelte-kit, etc.).
Environment
- Agent Brain version: 9.4.1
When --watch auto is enabled on a folder that contains the .agent-brain/ directory (i.e. the project root), the file watcher enters an infinite loop:
Root cause
AgentBrainWatchFilter in file_watcher_service.py uses a hardcoded ignore_dirs list that does not include .agent-brain/. The exclude_patterns from config.json are passed to the document loader only — they are not forwarded to watchfiles.awatch().
Expected behavior
.agent-brain/ should be excluded from the file watcher, either by adding it to AgentBrainWatchFilter.ignore_dirs or by passing config exclude_patterns dynamically to watchfiles.awatch().
Suggested fixes
ignore_dirs = {*DefaultFilter.ignore_dirs, "dist", "build", ".next", ".agent-brain"}
Environment