Skip to content

Commit 51d56a8

Browse files
Jasmine ZhangJasmine Zhang
authored andcommitted
fix(memory): skip qmd zero-hit sync retry
1 parent 51e2791 commit 51d56a8

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

extensions/memory-core/src/tools.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,30 @@ describe("memory_search unavailable payloads", () => {
291291
expect(getMemorySyncMockCalls()).toBe(0);
292292
});
293293

294+
it("does not force a sync retry for qmd zero-hit searches", async () => {
295+
let searchCalls = 0;
296+
setMemoryBackend("qmd");
297+
setMemorySearchImpl(async () => {
298+
searchCalls += 1;
299+
return [];
300+
});
301+
302+
const tool = createMemorySearchToolOrThrow({
303+
config: {
304+
agents: { list: [{ id: "main", default: true }] },
305+
memory: {
306+
backend: "qmd",
307+
citations: "off",
308+
qmd: { searchMode: "search" },
309+
},
310+
},
311+
});
312+
const result = await tool.execute("zero-hit-qmd", { query: "hidden thread codename" });
313+
314+
expect((result.details as { results?: unknown[] }).results ?? []).toEqual([]);
315+
expect(searchCalls).toBe(1);
316+
});
317+
294318
it("returns structured search debug metadata for qmd results", async () => {
295319
setMemoryBackend("qmd");
296320
setMemorySearchImpl(async (opts) => {

extensions/memory-core/src/tools.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,11 @@ export function createMemorySearchTool(options: {
477477
if (pausedIndexIdentityReason) {
478478
return;
479479
}
480-
if (rawResults.length === 0 && activeMemory.manager.sync) {
480+
if (
481+
rawResults.length === 0 &&
482+
activeMemory.manager.sync &&
483+
statusBeforeRetry.backend !== "qmd"
484+
) {
481485
await activeMemory.manager.sync({ reason: "search", force: true });
482486
rawResults = await activeMemory.manager.search(query, searchOptions);
483487
pausedIndexIdentityReason = resolvePausedMemoryIndexIdentityReason(

0 commit comments

Comments
 (0)