Skip to content

memory search --json prints results but does not exit with QMD backend #91821

@xpysgdhr

Description

@xpysgdhr

Summary

openclaw memory search <query> --json can print valid JSON results but keep the process alive when the QMD memory backend is active. Upstream callers then surface this as a timeout / embedding-provider style failure even though QMD itself is healthy and returns results quickly.

Environment

  • OpenClaw: 2026.6.5
  • Platform: macOS / Apple Silicon
  • Memory backend: QMD CLI backend (memory.backend=qmd)

Reproduction

openclaw memory search "QMD rebuild method" --json

Observed behavior in my environment:

  • The command emits valid JSON search results.
  • The process does not exit after output.
  • A caller with a 15s timeout reports a memory_search timeout / embedding-provider error.

Diagnostics

QMD itself appears healthy:

qmd doctor
qmd search "QMD rebuild method"

In my environment:

  • qmd doctor passes embedding freshness, fingerprint, and vector sample checks.
  • direct qmd search returns quickly.
  • openclaw memory search ... --json prints results, then hangs.

This makes the issue look like OpenClaw CLI/runtime exit handling after JSON output rather than a QMD index or embedding provider failure.

Local hotfix that resolves it

In the generated runtime, runMemorySearch() currently writes JSON and returns. Adding an explicit exit after JSON output resolves the hang locally:

if (opts.json) {
  defaultRuntime.writeJson({ results });
  setImmediate(() => process.exit(process.exitCode ?? 0));
  return;
}

After this local patch:

  • openclaw memory search ... --json exits with code 0 in ~3s.
  • the memory_search tool returns successfully with provider qmd.

Expected behavior

After printing JSON for memory search --json, the CLI should exit cleanly with status 0 when the search succeeds, even if the QMD manager leaves handles open internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.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: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    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