Skip to content

[Bug]: One-shot CLI can hang after completion due to cached memory manager FSWatcher handles #40365

Description

@Julbarth

Bug type

Crash (process/app exits or hangs)

Summary

In short-lived one-shot runs, OpenClaw can emit successful completion events but the process may stay alive due to cached memory manager watchers.

Steps to reproduce

  1. Use OpenClaw on main (before fix), with default memory settings (memory search enabled by default).
  2. Run a one-shot agent command that completes successfully (any prompt/provider that returns normally), e.g.:
    openclaw agent --message "Who is the current CEO of OpenAI?" --timeout 45
  3. Observe that completion is reached (message_end/lifecycle end emitted), but the process may remain alive instead of exiting promptly.
  4. If run under a wrapper timeout, the wrapper times out even though completion output is already present.
  5. Inspect active handles on the stuck process; FSWatcher is present.

Expected behavior

After successful completion, one-shot CLI process exits cleanly (exit code 0) without lingering handles.

Actual behavior

Process can stay alive after completion due to lingering watcher-backed memory manager caches.
User-visible symptom in automation/benchmarks: timeout/failure reported despite completed output.

OpenClaw version

2026.3.8

Operating system

macOS 14.0 (23A344)

Install method

No response

Logs, screenshots, and evidence

Impact and severity

  • Affected users: anyone running short-lived one-shot CLI flows (especially benchmark/CI wrappers with hard timeouts).
  • Severity: medium-high (causes false failures and unreliable automation).
  • Frequency: recurring when memory manager caches/watchers are initialized during a run.
  • Practical consequence:
    • Completed runs can be misclassified as timeouts.
    • Orphaned processes may accumulate.
    • Benchmark and CI reliability degrades.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangs

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions