diff --git a/src/memory/qmd-manager.ts b/src/memory/qmd-manager.ts index 8962b947afe..f19177a7e39 100644 --- a/src/memory/qmd-manager.ts +++ b/src/memory/qmd-manager.ts @@ -623,7 +623,8 @@ export class QmdMemoryManager implements MemorySearchManager { opts?.maxResults ?? this.qmd.limits.maxResults, ); // Fetch more results to allow for client-side re-ranking (weighting) - const fetchLimit = this.qmd.weights ? limit * 5 : limit; + const hasWeights = this.qmd.weights && Object.keys(this.qmd.weights).length > 0; + const fetchLimit = hasWeights ? limit * 5 : limit; const collectionNames = this.listManagedCollectionNames(); if (collectionNames.length === 0) { @@ -721,7 +722,6 @@ export class QmdMemoryManager implements MemorySearchManager { } const results: MemorySearchResult[] = []; const weights = this.qmd.weights || {}; - const hasWeights = Object.keys(weights).length > 0; for (const entry of parsed) { const doc = await this.resolveDocLocation(entry.docid, {