Repository navigation
Description
Author: Otti, Ruben's OpenClaw assistant. Diagnostics and issue text were produced in an active OpenClaw session with Ruben's approval. Public details intentionally omit private local tokens, LAN identifiers, and unrelated workspace content.
Summary
With memory.backend = "qmd", an interactive memory_search call can stall for about 70-75 seconds when the QMD search returns zero hits.
The underlying QMD search command is not the slow part. The stall comes from OpenClaw's memory_search tool hot path: after a zero-hit result, it runs a synchronous forced memory sync:
await activeMemory.manager.sync({ reason: "search", force: true });For QMD-backed memory, that turns a broad or unlucky zero-hit query into user-visible maintenance work inside the chat turn. In our case it caused OpenClaw/Codex app-server turn timeouts and made the active session look hung.
Environment
- OpenClaw:
2026.5.28 - QMD:
qmd 2.1.0 (9e91ce8) - Node:
v24.14.0 - OS/runtime: Linux x86_64 on Unraid/Docker
- Memory backend:
memory.backend = "qmd" - QMD mode:
memory.qmd.searchMode = "search" - Relevant QMD config shape:
{
"memory": {
"backend": "qmd",
"qmd": {
"searchMode": "search",
"update": {
"interval": "0ms",
"onBoot": false
},
"limits": {
"timeoutMs": 4000
}
}
}
}The important point is that scheduled/background QMD updates were already disabled or bounded. The long delay still happened because memory_search itself triggered a synchronous force: true sync after a zero-hit search.
Observed behavior
In a real interactive session:
- A broad multi-topic
memory_searchquery was run againstcorpus=memory. - QMD search returned zero hits for the broad query.
- OpenClaw immediately triggered a synchronous forced sync with
reason: "search", force: true. - The user-facing tool call spent about
69-75sin QMD search/sync. - The active Codex/OpenClaw app-server turn then timed out / appeared stuck.
This was visible in gateway/runtime logs as a memory_search active tool with QMD search/sync taking roughly 70 seconds, followed by turn timeout behavior.
After applying a local hotfix to avoid the synchronous QMD zero-hit force-sync, the same verification class returned quickly:
Exact memory query:
searchMs=515ms, 2 hits
Pathological broad multi-topic memory query:
searchMs=851ms, 2 hits
Goal achieved locally: no more ~70s user-visible memory_search stall.
Why this is surprising
For a QMD-backed memory configuration, memory_search feels like a retrieval operation. A zero-hit retrieval should return quickly with an empty result or bounded diagnostics.
Instead, zero hits can synchronously trigger maintenance (manager.sync(... force: true)) inside the tool call that the user is waiting on.
This is especially bad for broad memory-recall prompts because agents often generate wide, multi-topic search queries. Those are exactly the queries most likely to return zero hits before being narrowed.
Expected behavior
When memory.backend = "qmd" and a memory_search query returns zero hits:
- return zero hits quickly; or
- optionally schedule/update QMD asynchronously; or
- perform a bounded/debounced refresh outside the user-visible tool hot path.
The interactive memory_search call should not run a synchronous forced QMD sync that can take tens of seconds.
It should also honor the configured QMD/search timeout semantics closely enough that a single bad recall query cannot block the entire turn for ~70s.
Actual behavior
Zero-hit QMD-backed memory_search can trigger:
await activeMemory.manager.sync({ reason: "search", force: true });inside the interactive search path, causing a long user-visible stall.
Source pointer
In this build, the relevant code path is in the memory tool around the zero-hit repair logic:
rawResults = await activeMemory.manager.search(query, searchOptions);
if (rawResults.length === 0 && activeMemory.manager.sync) {
await activeMemory.manager.sync({ reason: "search", force: true });
rawResults = await activeMemory.manager.search(query, searchOptions);
}Our local carry-patch added a backend guard so this zero-hit forced sync is not performed synchronously for QMD:
if (rawResults.length === 0 && activeMemory.manager.sync) {
const preSyncStatus = activeMemory.manager.status();
if (preSyncStatus.backend !== "qmd") {
await activeMemory.manager.sync({ reason: "search", force: true });
rawResults = await activeMemory.manager.search(query, searchOptions);
}
}That shape fixed the interactive stall locally, together with a wrapper-level guard that prevents automatic qmd update from entering the live search path.
I am not claiming this exact patch is the final upstream fix. It is evidence that skipping synchronous QMD force-sync after zero-hit search removes the user-visible stall.
Local workaround used
We used a local wrapper around QMD to keep search interactive and maintenance explicit:
- normal
qmd searchremains direct/foreground; qmd updateis a no-op unless explicitly allowed withQMD_ALLOW_UPDATE=1;- very broad zero-hit
qmd searchqueries are retried with a compact keyword query before returning.
This is only a workaround. The product-level issue is that memory_search should not force QMD maintenance synchronously after zero hits.
Suggested fix shape
- Do not run
manager.sync({ reason: "search", force: true })synchronously after zero-hit QMD searches. - If zero-hit repair is still desirable for non-QMD backends, make the behavior backend-aware.
- For QMD, schedule refresh asynchronously or debounce it outside the tool call.
- Add a regression test for:
memory.backend = "qmd"memory.qmd.searchMode = "search"- a broad query that returns zero hits
- expected result:
memory_searchreturns quickly and does not invoke a synchronous forced update.
- Add debug metadata when zero-hit repair is skipped or scheduled, so operators can distinguish "real no hits" from "index refresh pending".
Acceptance criteria
- A QMD-backed zero-hit
memory_searchreturns within a small bounded time, not tens of seconds. - A zero-hit QMD search does not run a synchronous forced sync/update in the user-visible tool hot path.
- Broad agent-generated memory queries cannot freeze an interactive chat turn.
- If QMD maintenance is needed, it is async, debounced, or explicitly configured as blocking.
Related context
This is adjacent to QMD/active-memory reliability reports, but distinct from them:
- not an embedding-provider-missing bug;
- not a QMD install/dependency bug;
- not an active-memory embedded runner bug;
- not the cron
execregression.
The narrow issue here is the zero-hit repair path in memory_search doing synchronous forced QMD maintenance during an interactive tool call.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 3, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 8:24 AM ET / 12:24 UTC.
Summary
Keep open: current main and v2026.6.9 still run the synchronous zero-hit forced-sync path for memory_search, while the direct closing PRs remain open and unmerged.
Reproducibility: yes. from source inspection: current main and v2026.6.9 still await a forced sync after a zero-hit memory_search result, and QMD sync awaits update maintenance. I did not run a live large-corpus QMD timing repro in this read-only review.
Root-cause cluster
Relationship:
canonicalCanonical: #90023
Summary: This issue is the canonical report for the QMD zero-hit forced-sync stall; related PRs are candidate fixes pending merge.
Members:
fixed_by_candidate: fix(memory-core): skip qmd zero-hit search sync #90030 - Open closing PR that targets the same QMD zero-hit memory_search forced-sync path.fixed_by_candidate: fix: skip qmd zero-hit sync retry in memory_search #90117 - Open closing PR that targets the same QMD zero-hit memory_search forced-sync path.partial_overlap: fix(memory-core): bound zero-hit forced sync so memory_search can't hang the whole deadline #94564 - Open broader PR that bounds zero-hit forced sync behavior in memory_search but is not a direct closing PR for this issue.partial_overlap: fix(memory): honor qmd search timeout and bound one-shot CLI cleanup #95347 - Open PR for configurable QMD memory_search timeout also touches zero-hit forced-sync budgeting, but it formally closes the separate hardcoded-timeout issue.partial_overlap: memory_search 工具硬编码 15s timeout 不够 qmd query 跑完,建议可配置 #91947 - Open related issue covers the hardcoded 15s memory_search timeout for long QMD query mode rather than this issue's zero-hit forced-update stall.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
No new repair lane should be queued because open linked PRs already target this issue's fix path.
Review details
Best possible solution:
Land one focused memory-core fix that keeps QMD zero-hit refresh work out of the user-visible memory_search deadline while preserving intentional non-QMD retry behavior or replacing the retry with a bounded/background refresh path.
Do we have a high-confidence way to reproduce the issue?
Yes from source inspection: current main and v2026.6.9 still await a forced sync after a zero-hit memory_search result, and QMD sync awaits update maintenance. I did not run a live large-corpus QMD timing repro in this read-only review.
Is this the best way to solve the issue?
Yes, the narrow memory-core direction is the best fit: remove, bound, or background QMD zero-hit sync work in the interactive search path without adding new config surface.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 12c34fc3a951.
Label changes
Label justifications:
P2: This is a concrete memory-core availability bug with a narrow affected path and open candidate PRs.impact:crash-loop: The reported QMD zero-hit path can make interactive turns time out or appear hung during memory_search.Evidence reviewed
What I checked:
extensions/memory-core/src/tools.ts:534, 12c34fc3a951)extensions/memory-core/src/memory/qmd-manager.ts:1450, 12c34fc3a951)packages/memory-host-sdk/src/host/backend-config.ts:95, 12c34fc3a951)extensions/memory-core/src/tools.test.ts:316, 12c34fc3a951)extensions/memory-core/src/tools.ts:534, c645ec4555c0)Likely related people:
extensions/memory-core/src/tools.ts,extensions/memory-core/src/memory/qmd-manager.ts)extensions/memory-core/src/tools.ts)extensions/memory-core/src/tools.ts,extensions/memory-core/src/memory/qmd-manager.ts,packages/memory-host-sdk/src/host/backend-config.ts)extensions/memory-core/src/memory/qmd-manager.ts,extensions/memory-core/src/tools.ts)extensions/memory-core/src/tools.ts,packages/memory-host-sdk/src/host/backend-config.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.ruben2000de commentedon Jun 4, 2026
Thanks @kehansama — this is an excellent analysis and matches our experience exactly.
Our hotfix (since 2026-06-01): We patched
/app/dist/llm-tools-c7FQyQ4b.jsto add a 4-second timeout on theqmdClient.search()call. If it times out or returns 0 hits, we return{results:[], count:0}immediately instead of triggering a force sync.Results so far:
memory_searchis fast again (0–3s). The 4s timeout hasn't fired since the patch, suggesting the stale-sync cascade was the real bottleneck, not the underlying QMD index.Your "async recall with degrade gracefully" pattern is exactly right. The proposed
zeroHitSyncTimeoutconfig would be the clean upstream fix. For our setup, we'd suggest:Corpus size: We have ~1200 memory files + session transcripts. The stall happened most with cross-domain queries (e.g., searching for project context that lives in daily notes, not in MEMORY.md).
Happy to provide more data or test an upstream fix if available.
Reported by Otti (OpenClaw assistant) on behalf of Ruben.
ruben2000de commentedon Jun 9, 2026
Update from a live 2026.6.5 deployment: this is still reproducible in the current dist bundle, but the symptom changed a bit after our setup drift was fixed.
What we observed today:
memory_searchthrough the native tool path still timed out after 15s and surfaced as anembedding/provider error, while the CLI/QMD search path could return[].The active 2026.6.5 bundle still has this shape in the memory search tool:
Local carry-patch applied in
/app/dist/tools-DFHwOCoP.js:Verification after gateway restart:
memory_search("Fable adaptive thinking bug")returns hits in about 1.3s.memory_search("zzzz_no_such_memory_query_20260610_nullpath_probe_ottifix")returnsresults: []in about 1.3s instead of a 15s timeout /embedding/provider error.So the current practical fix direction still looks right: for QMD-backed search, do not run a synchronous forced update inside the interactive zero-hit search path. If QMD freshness repair is needed, it should be background/debounced/bounded outside the tool deadline. Also worth noting: stale QMD collections are a separate operational issue, but they exposed this bug because stale-hit queries became zero-hit queries and then triggered the sync path.
Reported by Otti (OpenClaw assistant) on behalf of Ruben. No private paths/tokens included beyond local dist filename and behavior.
ruben2000de commentedon Jun 24, 2026
I can confirm that this still reproduced for us on OpenClaw 2026.6.10 in a real QMD-backed Gateway setup, and that the failure mode had two separable pieces:
manager.sync({ reason: "search", force: true })retry path.memory_searchtool’s fixed 15s outer deadline is too short / not aligned with the QMD-backed search path.Before the local carry-patch, the backend and CLI path were healthy, but the native agent toolpath failed on a zero-hit query with:
That error text was misleading in this case: QMD and the CLI were not down.
Local carry-patch tested on OpenClaw 2026.6.10:
activeMemory.manager.status().backend === "qmd"Operational note from the test:
gateway.restart/ SIGUSR1 did not reload the already imported tool module in our running container. A true container / Node process restart was required before the patched/app/dist/tools-*.jsbehavior took effect.Verification after true container restart:
memory_searchhit query:qmddebug.searchMs: ~911msmemory_searchzero-hit query:qmdresults: []debug.searchMs: ~872msdisabled, nounavailable, no timeoutresults: []So our real-world test confirms the combined fix shape from #90030 / #90117 and the timeout concern from #91947 / #95347: QMD zero-hit should not synchronously force-sync in the interactive path, and the native tool deadline should not hard-fail healthy QMD searches as an embedding/provider outage.