Skip to content

Feature: sync.watch should default to false in gateway mode #71335

Description

@chrisabad

Problem

When OpenClaw runs as a headless gateway (gateway.mode set), memorySearch.sync.watch defaults to true, which creates a chokidar file watcher for every memory file and extra path. On a multi-agent gateway this leaks file descriptors — we observed 1,292 chokidar watchers on a single instance.

Interactive desktop use benefits from near-real-time reindexing on file change. A headless gateway with many agents does not — files rarely change externally, and the FD cost is disproportionate.

Proposed Change

Default sync.watch to false when the process detects it is running in gateway mode (i.e., when gateway.mode is set to any non-CLI value).

Falling back:

  • agents.defaults.memorySearch.sync.watchfalse when gateway mode
  • Explicit sync.watch: true in config still wins (user override)
  • No change to CLI/desktop behavior (watch remains true by default)

Alternative considered

Replace chokidar awaitWriteFinish polling with native FSEvents on macOS to avoid per-file FD allocation. This would help on macOS but not on Linux gateways, and does not address the fundamental problem of O(n) watchers per agent.

Impact

  • Reduces FD consumption on gateway deployments from O(agents × files) to near-zero for the watch subsystem
  • No behavior change for desktop/CLI users
  • Users who want watch in gateway mode can opt in explicitly

Workaround

Set sync.watch: false in openclaw.json under agents.defaults.memorySearch.sync. This is already documented in the schema help text but should be the default for gateway mode.

Related: #64549 (watch does not auto-index new files — separate bug, but same subsystem)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions