mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(memory): return early for blank searches (#116034)
This commit is contained in:
@@ -1112,6 +1112,10 @@ export class MemoryIndexManager extends MemoryManagerEmbeddingOps implements Mem
|
||||
}
|
||||
|
||||
async search(query: string, opts?: MemoryIndexSearchOptions): Promise<MemorySearchResult[]> {
|
||||
const normalizedQuery = query.trim();
|
||||
if (!normalizedQuery) {
|
||||
return [];
|
||||
}
|
||||
const maxResults = opts?.maxResults ?? this.settings.query.maxResults;
|
||||
const minScore = opts?.minScore ?? this.settings.query.minScore;
|
||||
const hasActiveProject = (opts?.activeProjectKeys?.length ?? 0) > 0;
|
||||
@@ -1119,7 +1123,7 @@ export class MemoryIndexManager extends MemoryManagerEmbeddingOps implements Mem
|
||||
? Math.min(200, Math.max(maxResults, maxResults * 4))
|
||||
: maxResults;
|
||||
const candidateMinScore = hasActiveProject ? minScore / 1.15 : minScore;
|
||||
const results = await this.searchUnranked(query, {
|
||||
const results = await this.searchUnranked(normalizedQuery, {
|
||||
...opts,
|
||||
maxResults: candidateMaxResults,
|
||||
minScore: candidateMinScore,
|
||||
@@ -1131,15 +1135,11 @@ export class MemoryIndexManager extends MemoryManagerEmbeddingOps implements Mem
|
||||
}
|
||||
|
||||
private async searchUnranked(
|
||||
query: string,
|
||||
normalizedQuery: string,
|
||||
opts?: MemoryIndexSearchOptions,
|
||||
): Promise<MemorySearchResult[]> {
|
||||
return await this.withManagerOperation(async () => {
|
||||
opts?.onDebug?.({ backend: "builtin" });
|
||||
const normalizedQuery = query.trim();
|
||||
if (!normalizedQuery) {
|
||||
return [];
|
||||
}
|
||||
if (this.providerRequirement.mode === "required") {
|
||||
await this.ensureProviderInitialized();
|
||||
this.assertRequiredProviderAvailable("search");
|
||||
|
||||
Reference in New Issue
Block a user