Skip to content

feat: workspace file watching for automatic re-indexing #5849

@kshitijk4poor

Description

@kshitijk4poor

Problem

The workspace knowledgebase only re-indexes on explicit hermes workspace index or via the debounce-on-retrieve path (30s cooldown). Files modified between retrieval calls may serve stale results.

Research

  • Continue.dev: Uses VS Code FileSystemWatcher with 5-second debounce and AbortController for cancellation
  • PrivateGPT: IngestWatcher polls filesystem every 5 seconds via simple loop
  • Khoj: No file watching — entirely API-triggered re-indexing

Proposed approach

Add an optional lightweight polling watcher:

  1. New config key: knowledgebase.watch_for_changes: false (off by default)
  2. When enabled, spawn a background thread that polls workspace roots every N seconds (configurable, default 10)
  3. On change detection (mtime comparison), trigger index_workspace_knowledgebase() in background
  4. Use existing _AUTO_INDEX_DEBOUNCE_SECONDS to avoid redundant re-indexes
  5. New module: agent/workspace_watcher.py

Related

Part of workspace foundation (#5840)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginstype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions