fix(memory/qmd): scope query to managed collections (#11645)

This commit is contained in:
Vignesh
2026-02-09 23:35:27 -08:00
committed by GitHub
parent 40919b1fc8
commit ef4a0e92b7
5 changed files with 148 additions and 2 deletions

View File

@@ -262,7 +262,12 @@ export class QmdMemoryManager implements MemorySearchManager {
this.qmd.limits.maxResults,
opts?.maxResults ?? this.qmd.limits.maxResults,
);
const args = ["query", trimmed, "--json", "-n", String(limit)];
const collectionFilterArgs = this.buildCollectionFilterArgs();
if (collectionFilterArgs.length === 0) {
log.warn("qmd query skipped: no managed collections configured");
return [];
}
const args = ["query", trimmed, "--json", "-n", String(limit), ...collectionFilterArgs];
let stdout: string;
try {
const result = await this.runQmd(args, { timeoutMs: this.qmd.limits.timeoutMs });
@@ -975,4 +980,12 @@ export class QmdMemoryManager implements MemorySearchManager {
new Promise<void>((resolve) => setTimeout(resolve, SEARCH_PENDING_UPDATE_WAIT_MS)),
]);
}
private buildCollectionFilterArgs(): string[] {
const names = this.qmd.collections.map((collection) => collection.name).filter(Boolean);
if (names.length === 0) {
return [];
}
return names.flatMap((name) => ["-c", name]);
}
}