@@ -1112,14 +1112,18 @@ export class MemoryIndexManager extends MemoryManagerEmbeddingOps implements Mem
11121112 }
11131113
11141114 async search ( query : string , opts ?: MemoryIndexSearchOptions ) : Promise < MemorySearchResult [ ] > {
1115+ const normalizedQuery = query . trim ( ) ;
1116+ if ( ! normalizedQuery ) {
1117+ return [ ] ;
1118+ }
11151119 const maxResults = opts ?. maxResults ?? this . settings . query . maxResults ;
11161120 const minScore = opts ?. minScore ?? this . settings . query . minScore ;
11171121 const hasActiveProject = ( opts ?. activeProjectKeys ?. length ?? 0 ) > 0 ;
11181122 const candidateMaxResults = hasActiveProject
11191123 ? Math . min ( 200 , Math . max ( maxResults , maxResults * 4 ) )
11201124 : maxResults ;
11211125 const candidateMinScore = hasActiveProject ? minScore / 1.15 : minScore ;
1122- const results = await this . searchUnranked ( query , {
1126+ const results = await this . searchUnranked ( normalizedQuery , {
11231127 ...opts ,
11241128 maxResults : candidateMaxResults ,
11251129 minScore : candidateMinScore ,
@@ -1131,15 +1135,11 @@ export class MemoryIndexManager extends MemoryManagerEmbeddingOps implements Mem
11311135 }
11321136
11331137 private async searchUnranked (
1134- query : string ,
1138+ normalizedQuery : string ,
11351139 opts ?: MemoryIndexSearchOptions ,
11361140 ) : Promise < MemorySearchResult [ ] > {
11371141 return await this . withManagerOperation ( async ( ) => {
11381142 opts ?. onDebug ?.( { backend : "builtin" } ) ;
1139- const normalizedQuery = query . trim ( ) ;
1140- if ( ! normalizedQuery ) {
1141- return [ ] ;
1142- }
11431143 if ( this . providerRequirement . mode === "required" ) {
11441144 await this . ensureProviderInitialized ( ) ;
11451145 this . assertRequiredProviderAvailable ( "search" ) ;
0 commit comments