Repository navigation
Description
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" --jsonObserved 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_searchtimeout / embedding-provider error.
Diagnostics
QMD itself appears healthy:
qmd doctor
qmd search "QMD rebuild method"In my environment:
qmd doctorpasses embedding freshness, fingerprint, and vector sample checks.- direct
qmd searchreturns quickly. openclaw memory search ... --jsonprints 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 ... --jsonexits with code 0 in ~3s.- the
memory_searchtool returns successfully with providerqmd.
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
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 10, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 9, 2026, 11:55 PM ET / 03:55 UTC.
Summary
Keep open: current main still has the same
memory search --jsoncontrol flow as the reported v2026.6.5 build, so there is not enough evidence to close this as fixed. The report is detailed and points at a real CLI/QMD cleanup boundary that should get a focused fix and regression proof.Reproducibility: yes. there is a high-confidence reproduction recipe from the report: run
openclaw memory search "QMD rebuild method" --jsonwithmemory.backend=qmdon v2026.6.5. I did not run a live QMD setup here, but current main still follows the same JSON-return and cleanup path.Next step
A focused repair is plausible, but the worker must first reproduce or instrument the QMD-backed hang rather than blindly adding
process.exit.Review details
Best possible solution:
Make the QMD-backed
memory search --jsonCLI path emit JSON and terminate cleanly by fixing or bounding the CLI-owned QMD manager/process cleanup path, then add regression proof that a successful JSON search exits.Do we have a high-confidence way to reproduce the issue?
Yes, there is a high-confidence reproduction recipe from the report: run
openclaw memory search "QMD rebuild method" --jsonwithmemory.backend=qmdon v2026.6.5. I did not run a live QMD setup here, but current main still follows the same JSON-return and cleanup path.Is this the best way to solve the issue?
No, the proposed local
process.exithotfix is a useful signal but not clearly the best permanent fix because it can mask leaked handles. The better fix is to identify the QMD/manager handle that survives after JSON output and close or bound it in the CLI-owned path.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
process.exithotfix proves a workaround but may bypass normal manager cleanup; a fix should avoid hiding leaked handles unless maintainers explicitly choose a forced-exit CLI policy.Codex review notes: model gpt-5.5, reasoning high; reviewed against bf89552e6783.
Label changes
Label changes:
P2: This is a normal-priority memory/QMD CLI bug with real automation impact, but it is limited to a specific backend and command path.impact:crash-loop: The reported failure is a CLI process hang after successful output, which affects process availability for upstream callers.impact:session-state: The timeout makesmemory_searchappear unavailable even when QMD returned results, degrading agent memory/context retrieval.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.Label justifications:
P2: This is a normal-priority memory/QMD CLI bug with real automation impact, but it is limited to a specific backend and command path.impact:crash-loop: The reported failure is a CLI process hang after successful output, which affects process availability for upstream callers.impact:session-state: The timeout makesmemory_searchappear unavailable even when QMD returned results, degrading agent memory/context retrieval.Evidence reviewed
Acceptance criteria:
openclaw memory search <query> --jsonexits with code 0 after printing resultsWhat I checked:
runMemorySearchstill writes{ results }and returns foropts.json; there is no explicit exit or bounded post-output cleanup in that branch on current main. (extensions/memory-core/src/cli.runtime.ts:1284, bf89552e6783)finally, so a QMD-manager or child-process cleanup hang can keep the command alive after JSON has already been written. (extensions/memory-core/src/cli.runtime.ts:495, bf89552e6783)mode === "cli"before watcher/timer setup, while search still runs direct QMD or mcporter-backed search attempts. (extensions/memory-core/src/memory/qmd-manager.ts:474, bf89552e6783)extensions/memory-core/src/cli.test.ts:1211, bf89552e6783)git diff v2026.6.5..HEAD -- extensions/memory-core/src/cli.runtime.tsis empty; the only memory diff since the release is unrelated QMD collection path enrichment. (extensions/memory-core/src/cli.runtime.ts:1284, bf89552e6783)extensions/memory-core/src/cli.runtime.ts:1229, 696c1ecd2068)Likely related people:
extensions/memory-core/src/cli.runtime.ts,extensions/memory-core/src/memory/qmd-manager.ts,packages/memory-host-sdk/src/host/qmd-process.ts)extensions/memory-core/src/cli.runtime.ts,extensions/memory-core/src/memory/qmd-manager.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.bladin commentedon Jun 10, 2026
Fixed by #91864.
The fix adds an explicit process.exit() call after JSON output in the memory search command, preventing the process from hanging when QMD backend leaves internal handles open.
All unit tests pass.