@@ -2086,12 +2086,20 @@ const memoryLanceDBProPlugin = {
20862086 if ( config . autoCapture !== false ) {
20872087 api . on ( "agent_end" , async ( event , ctx ) => {
20882088 if ( ! event . success || ! event . messages || event . messages . length === 0 ) {
2089+ api . logger . info (
2090+ `memory-lancedb-pro: auto-capture skipped: ${ ! event . success ? "agent did not succeed" : "no messages in event" } ` ,
2091+ ) ;
20892092 return ;
20902093 }
20912094
2095+ const agentId = resolveHookAgentId ( ctx ?. agentId , ( event as any ) . sessionKey ) ;
2096+ let captureOutcome = "unknown" ;
2097+ let dupSkipped = 0 ;
2098+ let stored = 0 ;
2099+ let captureEligibleCount = 0 ;
2100+ let captureTextCount = 0 ;
2101+
20922102 try {
2093- // Determine agent ID and default scope
2094- const agentId = resolveHookAgentId ( ctx ?. agentId , ( event as any ) . sessionKey ) ;
20952103 const accessibleScopes = scopeManager . getAccessibleScopes ( agentId ) ;
20962104 const defaultScope = scopeManager . getDefaultScope ( agentId ) ;
20972105 const sessionKey = ctx ?. sessionKey || ( event as any ) . sessionKey || "unknown" ;
@@ -2152,6 +2160,7 @@ const memoryLanceDBProPlugin = {
21522160 }
21532161 }
21542162
2163+ captureEligibleCount = eligibleTexts . length ;
21552164 const conversationKey = buildAutoCaptureConversationKeyFromSessionKey ( sessionKey ) ;
21562165 const pendingIngressTexts = conversationKey
21572166 ? [ ...( autoCapturePendingIngressTexts . get ( conversationKey ) || [ ] ) ]
@@ -2204,10 +2213,12 @@ const memoryLanceDBProPlugin = {
22042213 api . logger . debug (
22052214 `memory-lancedb-pro: auto-capture collected ${ texts . length } text(s) for agent ${ agentId } (minMessages=${ minMessages } , smartExtraction=${ smartExtractor ? "on" : "off" } )` ,
22062215 ) ;
2216+ captureTextCount = texts . length ;
22072217 if ( texts . length === 0 ) {
2208- api . logger . debug (
2218+ api . logger . info (
22092219 `memory-lancedb-pro: auto-capture found no eligible texts after filtering for agent ${ agentId } ` ,
22102220 ) ;
2221+ captureOutcome = "no-eligible-texts" ;
22112222 return ;
22122223 }
22132224 if ( texts . length > 0 ) {
@@ -2223,9 +2234,10 @@ const memoryLanceDBProPlugin = {
22232234 // Pre-filter: embedding-based noise detection (language-agnostic)
22242235 const cleanTexts = await smartExtractor . filterNoiseByEmbedding ( texts ) ;
22252236 if ( cleanTexts . length === 0 ) {
2226- api . logger . debug (
2237+ api . logger . info (
22272238 `memory-lancedb-pro: all texts filtered as embedding noise for agent ${ agentId } ` ,
22282239 ) ;
2240+ captureOutcome = "embedding-noise-filtered" ;
22292241 return ;
22302242 }
22312243 if ( cleanTexts . length >= minMessages ) {
@@ -2241,14 +2253,16 @@ const memoryLanceDBProPlugin = {
22412253 api . logger . info (
22422254 `memory-lancedb-pro: smart-extracted ${ stats . created } created, ${ stats . merged } merged, ${ stats . skipped } skipped for agent ${ agentId } `
22432255 ) ;
2256+ captureOutcome = "smart-extracted" ;
2257+ stored = stats . created + stats . merged ;
22442258 return ; // Smart extraction handled everything
22452259 }
22462260
22472261 api . logger . info (
22482262 `memory-lancedb-pro: smart extraction produced no persisted memories for agent ${ agentId } (created=${ stats . created } , merged=${ stats . merged } , skipped=${ stats . skipped } ); falling back to regex capture` ,
22492263 ) ;
22502264 } else {
2251- api . logger . debug (
2265+ api . logger . info (
22522266 `memory-lancedb-pro: auto-capture skipped smart extraction for agent ${ agentId } (${ cleanTexts . length } < ${ minMessages } )` ,
22532267 ) ;
22542268 }
@@ -2271,6 +2285,7 @@ const memoryLanceDBProPlugin = {
22712285 api . logger . info (
22722286 `memory-lancedb-pro: regex fallback found 0 capturable texts for agent ${ agentId } ` ,
22732287 ) ;
2288+ captureOutcome = "regex-no-match" ;
22742289 return ;
22752290 }
22762291
@@ -2279,7 +2294,6 @@ const memoryLanceDBProPlugin = {
22792294 ) ;
22802295
22812296 // Store each capturable piece (limit to 3 per conversation)
2282- let stored = 0 ;
22832297 for ( const text of toCapture . slice ( 0 , 3 ) ) {
22842298 const category = detectCategory ( text ) ;
22852299 const vector = await embedder . embedPassage ( text ) ;
@@ -2298,6 +2312,10 @@ const memoryLanceDBProPlugin = {
22982312 }
22992313
23002314 if ( existing . length > 0 && existing [ 0 ] . score > 0.95 ) {
2315+ api . logger . debug (
2316+ `memory-lancedb-pro: auto-capture skipped duplicate (similarity=${ existing [ 0 ] . score . toFixed ( 3 ) } ) for agent ${ agentId } ` ,
2317+ ) ;
2318+ dupSkipped ++ ;
23012319 continue ;
23022320 }
23032321
@@ -2338,9 +2356,17 @@ const memoryLanceDBProPlugin = {
23382356 api . logger . info (
23392357 `memory-lancedb-pro: auto-captured ${ stored } memories for agent ${ agentId } in scope ${ defaultScope } ` ,
23402358 ) ;
2359+ captureOutcome = "regex-captured" ;
2360+ } else {
2361+ captureOutcome = "regex-all-duplicates" ;
23412362 }
23422363 } catch ( err ) {
2364+ captureOutcome = "error" ;
23432365 api . logger . warn ( `memory-lancedb-pro: capture failed: ${ String ( err ) } ` ) ;
2366+ } finally {
2367+ api . logger . info (
2368+ `memory-lancedb-pro: auto-capture pipeline result for agent ${ agentId } : outcome=${ captureOutcome } , messages=${ event . messages . length } , eligible=${ captureEligibleCount } , texts=${ captureTextCount } , stored=${ stored } ${ dupSkipped > 0 ? `, dupSkipped=${ dupSkipped } ` : "" } ` ,
2369+ ) ;
23442370 }
23452371 } ) ;
23462372 }
0 commit comments