@@ -17,21 +17,22 @@ import {
1717 hashText ,
1818 INVALID_PROJECT_ANNOTATION_KEY ,
1919 MEMORY_EMBEDDING_CACHE_TABLE ,
20+ MEMORY_INDEX_CHUNK_PROVENANCE_TABLE ,
21+ MEMORY_INDEX_CHUNK_RECALL_METADATA_TABLE ,
2022 MEMORY_INDEX_FTS_TABLE ,
2123 MEMORY_INDEX_VECTOR_TABLE ,
2224 remapChunkLines ,
2325 retryTransientMemoryRead ,
2426 runWithConcurrency ,
2527 stripMemoryAnnotationCarriers ,
2628 type MemoryChunk ,
27- type MemorySource ,
2829 type MemoryEntryProvenance ,
29- MEMORY_INDEX_CHUNK_PROVENANCE_TABLE ,
30- MEMORY_INDEX_CHUNK_RECALL_METADATA_TABLE ,
30+ type MemorySource ,
3131} from "openclaw/plugin-sdk/memory-core-host-engine-storage" ;
3232import { MAX_TIMER_TIMEOUT_MS , resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime" ;
3333import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env" ;
3434import { runSqliteImmediateTransactionSync } from "openclaw/plugin-sdk/sqlite-runtime" ;
35+ import { readSessionResetRecallCutoffMetadata } from "../session-reset-recall-metadata.js" ;
3536import type { EmbeddingProvider } from "./embeddings.js" ;
3637import {
3738 MEMORY_BATCH_FAILURE_LIMIT ,
@@ -59,6 +60,7 @@ import {
5960 resolveMemoryIndexProviderIdentities ,
6061 type MemoryIndexProviderIdentity ,
6162} from "./manager-reindex-state.js" ;
63+ import { chunkSessionContentAtResetBoundary } from "./manager-reset-chunk-boundary.js" ;
6264import {
6365 MemoryManagerSyncOps ,
6466 type MemoryIndexWorkItem ,
@@ -1121,11 +1123,19 @@ export abstract class MemoryManagerEmbeddingOps extends MemoryManagerSyncOps {
11211123 ( normalizedEntryPath === "MEMORY.md" || normalizedEntryPath === "USER.md" ) ;
11221124 const indexingContent =
11231125 options . source === "memory" ? stripMemoryAnnotationCarriers ( content ) : content ;
1126+ const chunkOptions = { ...this . settings . chunking , perEntry } ;
11241127 const baseChunks = filterNonEmptyMemoryChunks (
1125- chunkMarkdown ( indexingContent , {
1126- ...this . settings . chunking ,
1127- perEntry,
1128- } ) ,
1128+ options . source === "sessions"
1129+ ? chunkSessionContentAtResetBoundary ( {
1130+ content : indexingContent ,
1131+ cutoffLine : ( ( ) => {
1132+ const cutoff = readSessionResetRecallCutoffMetadata ( entry ) ;
1133+ return cutoff . state === "valid" ? cutoff . cutoffLine : undefined ;
1134+ } ) ( ) ,
1135+ lineMap : entry . lineMap ,
1136+ chunking : chunkOptions ,
1137+ } )
1138+ : chunkMarkdown ( indexingContent , chunkOptions ) ,
11291139 ) ;
11301140 for ( const chunk of baseChunks ) {
11311141 chunk . provenance = this . resolveChunkProvenance (
0 commit comments