@@ -71,6 +71,28 @@ type MemoryManagerPurpose = Parameters<typeof getMemorySearchManager>[0]["purpos
7171
7272type MemorySourceName = "memory" | "sessions" ;
7373
74+ function formatMemoryIndexIdentityWarning (
75+ status : ReturnType < MemoryManager [ "status" ] > ,
76+ agentId : string ,
77+ ) : {
78+ reason : string ;
79+ fix : string ;
80+ } | null {
81+ const indexIdentity = asRecord ( asRecord ( status . custom ) ?. indexIdentity ) ;
82+ const reason =
83+ ( indexIdentity ?. status === "mismatched" || indexIdentity ?. status === "missing" ) &&
84+ typeof indexIdentity . reason === "string"
85+ ? indexIdentity . reason
86+ : undefined ;
87+ if ( ! reason ) {
88+ return null ;
89+ }
90+ return {
91+ reason,
92+ fix : `Run: openclaw memory status --index --agent ${ agentId } ` ,
93+ } ;
94+ }
95+
7496type SourceScan = {
7597 source : MemorySourceName ;
7698 totalFiles : number | null ;
@@ -868,6 +890,12 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
868890 lines . push ( `${ label ( "Embeddings error" ) } ${ warn ( embeddingProbe . error ) } ` ) ;
869891 }
870892 }
893+ const identityWarning = formatMemoryIndexIdentityWarning ( status , agentId ) ;
894+ if ( identityWarning ) {
895+ lines . push ( `${ label ( "Index identity" ) } ${ warn ( identityWarning . reason ) } ` ) ;
896+ lines . push ( `${ label ( "Vector search" ) } ${ warn ( "paused until memory is rebuilt" ) } ` ) ;
897+ lines . push ( `${ label ( "Fix" ) } ${ muted ( identityWarning . fix ) } ` ) ;
898+ }
871899 if ( status . sourceCounts ?. length ) {
872900 lines . push ( label ( "By source" ) ) ;
873901 for ( const entry of status . sourceCounts ) {
@@ -1256,6 +1284,15 @@ export async function runMemorySearch(
12561284 defaultRuntime . writeJson ( { results } ) ;
12571285 return ;
12581286 }
1287+ const identityWarning =
1288+ typeof manager . status === "function"
1289+ ? formatMemoryIndexIdentityWarning ( manager . status ( ) , agentId )
1290+ : null ;
1291+ if ( identityWarning ) {
1292+ defaultRuntime . error (
1293+ `Memory index warning: ${ identityWarning . reason } . Vector memory search is paused until the index is rebuilt. ${ identityWarning . fix } ` ,
1294+ ) ;
1295+ }
12591296 if ( results . length === 0 ) {
12601297 defaultRuntime . log ( "No matches." ) ;
12611298 return ;
0 commit comments