#11364: fix(memory/qmd): prevent cascading failure when query fails or returns empty
stale
Cluster:
QMD Memory Management Fixes
- Allow qmd query mode with automatic fallback to search on failure
- Check both stdout and stderr for 'no results found' marker
- Read OPENCLAW_QMD_MODE from spawn env to avoid surprises
- Only ignore top-level /memory/ in .gitignore
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR hardens the `qmd` memory query path by (1) allowing an automatic fallback from query→search when the query invocation fails or produces empty output, (2) detecting the “no results found” marker in both stdout and stderr, and (3) ensuring `OPENCLAW_QMD_MODE` is read from the spawned process environment (rather than surprising defaults). It also tightens `.gitignore` to only ignore the top-level `/memory/` directory instead of broader patterns.
These changes fit into the memory subsystem by making the QMD manager more resilient to tool failures/empty-result edge cases while keeping repo hygiene around generated memory artifacts more precise.
<h3>Confidence Score: 3/5</h3>
- Mostly safe, but has a couple edge-case behaviors that can break intended fallback semantics.
- The changes are localized and improve robustness, but the fallback behavior is one-directional (query→search only) and the stderr/no-results handling relies on assumptions that can become brittle with small refactors. Fixing these would reduce surprising failures and align behavior with the PR intent.
- src/memory/qmd-manager.ts
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#15307: fix(memory): handle mixed/no-results QMD query output
by MohammadErfan-Jabbari · 2026-02-13
86.4%
#9624: fix(memory): resolve QMD search returning empty results [AI-assisted]
by kowshik24 · 2026-02-05
85.0%
#21471: fix: check QMD backend before memory search config
by lbo728 · 2026-02-20
82.6%
#9149: Fix: Allow QMD backend to work without OpenAI auth
by vishaltandale00 · 2026-02-04
82.0%
#20125: fix(doctor): skip memorySearch provider check when using QMD backend
by brandonwise · 2026-02-18
79.8%
#20085: Fix QMD memory_search empty results when docid key changes
by rylena · 2026-02-18
79.7%
#11179: fix(memory): replace confusing "No API key" errors in memory tools ...
by liuxiaopai-ai · 2026-02-07
79.5%
#9381: Fix: Allow QMD CLI memory search when scope is restrictive
by vishaltandale00 · 2026-02-05
79.3%
#17660: fix: skip embedding provider check in doctor when QMD backend is co...
by echoVic · 2026-02-16
78.9%
#22937: fix: remove legacy unsuffixed QMD collections on upgrade
by sud0n1m-ziggy · 2026-02-21
78.2%